Annotation of html5/spec/syntax.html, revision 1.955
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.955 ! 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.4051.</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.893 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="text-level-semantics.html#the-wbr-element">wbr</a></code></dd>
1.1 mike 422:
1.373 mike 423: <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1 mike 424:
425: <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 426: noscript don't count as raw text for syntax purposes -->
1.1 mike 427:
1.373 mike 428: <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1 mike 429:
1.159 mike 430: <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 431:
1.373 mike 432: <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1 mike 433:
1.724 mike 434: <dd>Elements from the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>
435: and the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dd>
1.1 mike 436:
1.373 mike 437: <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1 mike 438:
439: <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
440: elements.</dd>
441:
442: </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373 mike 443: and end of elements in the markup. <a href="#raw-text-elements" title="raw text
444: elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
445: elements">RCDATA</a>, and <a href="#normal-elements" title="normal
446: elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
447: begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
448: indicate where they end. The start and end tags of certain
449: <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 450: later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
451: elements</a> only have a start tag; end tags must not be
1.373 mike 452: specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
453: elements</a> must either have a start tag and an end tag, or a
454: start tag that is marked as self-closing, in which case they must
455: not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1 mike 456: start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
457: in certain cases</a>) and just before the end tag (which again,
458: <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
459: cases</a>). The exact allowed contents of each individual element
460: depends on the content model of that element, as described earlier
461: in this specification. Elements must not contain content that their
462: content model disallows. In addition to the restrictions placed on
463: the contents by those content models, however, the five types of
1.123 mike 464: 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 465: no end tag, no content can be put between the start tag and the end
1.373 mike 466: 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
467: 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
468: must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1 mike 469: There are also <a href="#cdata-rcdata-restrictions">further
1.373 mike 470: restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
471: self-closing can't have any contents (since, again, as there's no
472: end tag, no content can be put between the start tag and the end
473: tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
474: 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 475: 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 476:
477: <p>The HTML syntax does not support namespace
478: declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
479:
480: <p>For instance, consider the following HTML fragment:</p>
481:
482: <pre><p>
483: <svg>
484: <metadata>
485: <!-- this is invalid -->
486: <cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/>
487: </metadata>
488: </svg>
489: </p></pre>
490:
491: <p>The innermost element, <code title="">cdr:license</code>, is
492: actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
493: XML). In fact, as the comment in the fragment above says, the
494: fragment is actually non-conforming. This is because the SVG
495: specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
496:
497: </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 498: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
499: <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1 mike 500: content they are allowed to hold, beyond the restrictions imposed by
501: the content model and those described in this paragraph. Those
1.123 mike 502: restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1 mike 503: giving the element's name. HTML elements all have names that only
1.464 mike 504: use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
505: NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
506: Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
507: Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462 mike 508: elements</a>, may be written with any mix of lower- and uppercase
509: letters that, when converted to all-lowercase, matches the element's
1.895 mike 510: 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 511: following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588 mike 512: SIGN character (<).</li>
1.1 mike 513:
514: <li>The next few characters of a start tag must be the element's
515: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
516:
517: <li>If there are to be any attributes in the next step, there must
518: first be one or more <a href="infrastructure.html#space-character" title="space character">space
519: characters</a>.</li>
520:
521: <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
522: below. Attributes may be separated from each other by one or more
523: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
524:
1.766 mike 525: <li>After the attributes, or after the <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a> if there are no attributes,
526: there may be one or more <a href="infrastructure.html#space-character" title="space character">space
527: characters</a>. (Some attributes are required to be followed by
528: a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes
529: section</a> below.)</li>
1.1 mike 530:
531: <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373 mike 532: or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588 mike 533: element</a>, then there may be a single U+002F SOLIDUS character
534: (/). This character has no effect on <a href="#void-elements">void elements</a>,
535: but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
536: self-closing.</li>
1.1 mike 537:
538: <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588 mike 539: SIGN character (>).</li>
1.1 mike 540:
1.895 mike 541: </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 542: following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588 mike 543: SIGN character (<).</li>
1.1 mike 544:
545: <li>The second character of an end tag must be a U+002F SOLIDUS
1.588 mike 546: character (/).</li>
1.1 mike 547:
548: <li>The next few characters of an end tag must be the element's
549: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
550:
551: <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
552: character">space characters</a>.</li>
553:
1.588 mike 554: <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
555: character (>).</li>
1.1 mike 556:
1.955 ! mike 557: </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 558: 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 559: one or more characters other than the <a href="infrastructure.html#space-character" title="space
560: character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
561: MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
562: (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
563: the control characters, and any characters that are not defined by
1.462 mike 564: Unicode. In the HTML syntax, attribute names, even those for
565: <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
566: and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123 mike 567: 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 568: 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 569: 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 570:
571: <dd>
572:
573: <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
1.837 mike 574: name</a>. The value is implicitly the empty string.</p>
1.1 mike 575:
576: <div class="example">
577:
578: <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
579: the empty attribute syntax:</p>
580:
581: <pre><input <em>disabled</em>></pre>
582:
583: </div>
584:
585: <p>If an attribute using the empty attribute syntax is to be
586: followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
587: character</a> separating the two.</p>
588:
589: </dd>
590:
1.2 mike 591: <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1 mike 592:
593: <dd>
594:
595: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
596: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
597: characters</a>, followed by a single U+003D EQUALS SIGN
598: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
599: character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
600: addition to the requirements given above for attribute values,
601: must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588 mike 602: characters</a>, any U+0022 QUOTATION MARK characters ("),
603: U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
604: characters (=), U+003C LESS-THAN SIGN characters (<), U+003E
605: GREATER-THAN SIGN characters (>), or U+0060 GRAVE ACCENT
606: characters (`), and must not be the empty string.</p>
1.463 mike 607:
608: <!-- The ` character is in this list on a temporary basis, waiting
609: for IE to fix it's parsing bug whereby it treats ` as an
610: attribute value delimiter. Otherwise, escaping software that
611: tries to be clever and not use quotes when it doesn't need to
612: could be tricked by an attacker.
613:
614: Posit a site that allows the user to input text that is used
615: verbatim in two attributes, such that the user can set the
616: first attribute's value to:
617:
618: `
619:
620: ...and the second to:
621:
622: ` onload='...payload...' end=x
623:
624: ...with the assumption that the site is going to not quote
625: the first one, and quote the second one with double quotes:
626:
627: <body title=` class="` onload='...payload...' end=x">
628:
629: In IE, this is treated as:
630:
631: <body title=' class="'
632: onload='...payload...'
633: end='x"'>
634:
635: -->
636:
1.1 mike 637:
638: <div class="example">
639:
640: <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
641: with the unquoted attribute value syntax:</p>
642:
643: <pre><input <em>value=yes</em>></pre>
644:
645: </div>
646:
647: <p>If an attribute using the unquoted attribute syntax is to be
1.101 mike 648: followed by another attribute or by the optional U+002F SOLIDUS
1.464 mike 649: 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 650: must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
651:
652: </dd>
653:
654: <dt>Single-quoted attribute value syntax</dt>
655:
656: <dd>
657:
658: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
659: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
660: characters</a>, followed by a single U+003D EQUALS SIGN
661: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
662: character">space characters</a>, followed by a single U+0027
1.588 mike 663: APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 664: addition to the requirements given above for attribute values,
1.588 mike 665: must not contain any literal U+0027 APOSTROPHE characters ('), and
666: finally followed by a second single U+0027 APOSTROPHE character
667: (').</p>
1.1 mike 668:
669: <div class="example">
670:
671: <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
672: single-quoted attribute value syntax:</p>
673:
674: <pre><input <em>type='checkbox'</em>></pre>
675:
676: </div>
677:
678: <p>If an attribute using the single-quoted attribute syntax is to
679: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
680: character</a> separating the two.</p>
681:
682: </dd>
683:
684: <dt>Double-quoted attribute value syntax</dt>
685:
686: <dd>
687:
688: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
689: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
690: characters</a>, followed by a single U+003D EQUALS SIGN
691: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
692: character">space characters</a>, followed by a single U+0022
1.588 mike 693: QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 694: addition to the requirements given above for attribute values,
1.588 mike 695: must not contain any literal U+0022 QUOTATION MARK characters ("),
696: and finally followed by a second single U+0022 QUOTATION MARK
697: character (").</p>
1.1 mike 698:
699: <div class="example">
700:
701: <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
702: double-quoted attribute value syntax:</p>
703:
704: <pre><input <em>name="be evil"</em>></pre>
705:
706: </div>
707:
708: <p>If an attribute using the double-quoted attribute syntax is to
709: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
710: character</a> separating the two.</p>
711:
712: </dd>
713:
714: </dl><p>There must never be two or more attributes on the same start tag
715: whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462 mike 716: each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
717: one of the namespaced attributes given by the local name and
718: namespace of the first and second cells of a row from the following
719: table, it must be written using the name given by the third cell
720: from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
1.724 mike 721: </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>
722: </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>
723: </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>
724: </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>
725: </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>
726: </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>
727: </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>
728: </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>
729: </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>
730: </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>
731: </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>
732: </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 733: </td></tr></tbody></table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.895 mike 734: 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 735: is not present; it is implied, but it is still there. An HTML
1.159 mike 736: document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1 mike 737: string <code title=""><html></code> doesn't appear anywhere in
1.159 mike 738: 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
739: 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
740: 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 741: 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
742: element is empty, or if the first thing inside the
1.159 mike 743: <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
744: tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
745: 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
746: 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 747: 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 748: 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 749: <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
1.872 mike 750: tag is present, the parser makes <style type="text/css"> and <script type="text/javascript"> elements
1.1 mike 751: between </head> and <body> end up in the <head> instead of implying
1.159 mike 752: 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
753: 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 754: 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 755: tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
756: immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422 mike 757: 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 758: tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
759: immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123 mike 760: <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 761: tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
762: immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
763: <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123 mike 764: 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 765: tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
766: immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
767: <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 768: <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306 mike 769: <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 770: <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>,
771: <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>,
772: <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>,
773: <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>,
774: <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 775: <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>,
776: element, or if there is no more content in the parent element and
1.123 mike 777: 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 778: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
779: 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 780: 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 781: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
782: 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 783: 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 784: <select>; commented out text below can handle the non-<select> case
1.123 mike 785: 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 786: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
787: <code>select</code> element and--> is immediately followed by
788: another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
789: that are ancestors of the <code>optgroup</code> element, up to and
790: including the first ancestor element that is not an
791: <code>optgroup</code> element, have no more content--> there is no
1.123 mike 792: more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1 mike 793: <select><optgroup></select>
794: <p id=x><optgroup></optgroup>x</p>
795: <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
796: <p><optgroup id=x><optgroup></optgroup>x</p>
797: <p><optgroup><optgroup id=x>x</p>
1.123 mike 798: --><!-- </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 799: tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
800: immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
801: it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123 mike 802: 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 803: first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
804: <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
805: 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 806: 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 807: <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123 mike 808: <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 809: tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
810: 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 811: 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 812: first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
813: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
814: 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
815: <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
816: tag</a> has been omitted. (It can't be omitted if the element is
1.123 mike 817: 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 818: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
819: 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 820: 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 821: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
822: immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123 mike 823: 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 824: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
825: immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123 mike 826: 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 827: tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
828: 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 829: 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 830: tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
831: 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 832: 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 833: 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 834: 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 835: elements, even though these elements are technically allowed inside
836: <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
837: described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
838: 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 839: 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
840: placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1 mike 841: 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>
842: elements. This does not affect the processing of the element. The
1.304 mike 843: otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381 mike 844: <em>must</em> be included if the element's contents themselves start
845: with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
846: otherwise the leading newline in the contents would be treated like
847: the optional newline, and ignored).</p><div class="example">
1.1 mike 848: <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
849: <pre><pre>Hello</pre></pre>
850: <pre><pre><br>Hello</pre></pre>
1.895 mike 851: </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 852: <a href="#rcdata-elements">RCDATA elements</a> must not contain any occurrences of the
853: string "<code title=""></</code>" (U+003C LESS-THAN SIGN, U+002F
854: SOLIDUS) followed by characters that case-insensitively match the
855: tag name of the element followed by one of U+0009 CHARACTER
856: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D
857: CARRIAGE RETURN (CR), U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or
1.895 mike 858: 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 859: attributes, and comments. Text must consist of Unicode characters.
860: Text must not contain U+0000 characters. Text must not contain
1.316 mike 861: permanently undefined Unicode characters (noncharacters). Text must
862: not contain control characters other than <a href="infrastructure.html#space-character" title="space
863: character">space characters</a>. Extra constraints are placed on
864: what is and what is not allowed in text based on where the text is
1.895 mike 865: 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 866: represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
867: LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.882 mike 868: U+000A LINE FEED (LF) characters in that order.</p><p>Where <a href="#syntax-charref" title="syntax-charref">character references</a>
869: are allowed, a character reference of a U+000A LINE FEED (LF)
870: character (but not a U+000D CARRIAGE RETURN (CR) character) also
1.895 mike 871: 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 872: to escape characters that couldn't otherwise legally be included in
1.588 mike 873: <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
874: (&). Following this, there are three possible kinds of character
875: references:</p><dl><dt>Named character references</dt>
1.1 mike 876:
877: <dd>The ampersand must be followed by one of the names given in the
878: <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677 mike 879: case. <span class="impl">The name must be one that is terminated by
880: a U+003B SEMICOLON character (;).</span></dd>
1.1 mike 881:
882:
883: <dt>Decimal numeric character reference</dt>
884:
885: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 886: character (#), followed by one or more digits in the range U+0030
887: DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
888: integer that corresponds to a Unicode code point that is allowed
889: according to the definition below. The digits must then be followed
890: by a U+003B SEMICOLON character (;).</dd>
1.1 mike 891:
892:
893: <dt>Hexadecimal numeric character reference</dt>
894:
895: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 896: character (#), which must be followed by either a U+0078 LATIN
897: SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
898: character (X), which must then be followed by one or more digits in
899: the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
900: LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
901: LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464 mike 902: representing a base-sixteen integer that corresponds to a Unicode
903: code point that is allowed according to the definition below. The
904: digits must then be followed by a U+003B SEMICOLON character
905: (;).</dd>
1.378 mike 906:
907: </dl><p>The numeric character reference forms described above are allowed
1.882 mike 908: to reference any Unicode code point other than U+0000, U+000D,
909: permanently undefined Unicode characters (noncharacters), and
910: control characters other than <a href="infrastructure.html#space-character" title="space character">space
1.378 mike 911: characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464 mike 912: ampersand</dfn> is a U+0026 AMPERSAND character (&) that is
1.897 mike 913: followed by one or more characters in the range U+0030 DIGIT ZERO
914: (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+007A
915: LATIN SMALL LETTER Z, and U+0041 LATIN CAPITAL LETTER A to U+005A
916: LATIN CAPITAL LETTER Z, followed by a U+003B SEMICOLON character
917: (;), where these characters do not match any of the names given in
918: 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 919: the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
920: MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
921: U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
922: LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
923: SQUARE BRACKET (<code title=""><![CDATA[</code>). Following this
924: sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
925: that the text must not contain the three character sequence U+005D
926: RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
927: GREATER-THAN SIGN (<code title="">]]></code>). Finally, the CDATA
928: section must be ended by the three character sequence U+005D RIGHT
929: SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.724 mike 930: SIGN (<code title="">]]></code>).</p><div class="example">
931:
932: <p>CDATA sections can only be used in foreign content (MathML or
933: SVG). In this example, a CDATA section is used to escape the
934: contents of an <code>ms</code> element:</p>
935:
936: <pre><p>You can add a string to a number, but this stringifies the number:</p>
937: <math>
938: <ms><![CDATA[x<y]]></ms>
939: <mo>+</mo>
940: <mn>3</mn>
941: <mo>=</mo>
942: <ms><![CDATA[x<y3]]></ms>
943: </math></pre>
944:
1.895 mike 945: </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 946: four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
947: MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title=""><!--</code>). Following this sequence, the comment may
948: have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
949: restriction that the text must not start with a single U+003E
1.588 mike 950: GREATER-THAN SIGN character (>), nor start with a U+002D
951: HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
952: (>) character, nor contain two consecutive U+002D HYPHEN-MINUS
953: characters (<code title="">--</code>), nor end with a U+002D
954: HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1 mike 955: the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123 mike 956: HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p><div class="impl">
1.1 mike 957:
1.895 mike 958: <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 959:
960: <p><i>This section only applies to user agents, data mining tools,
961: and conformance checkers.</i></p>
962:
963: <p class="note">The rules for parsing XML documents into DOM trees
964: are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
965: syntax</a>".</p>
966:
967: <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
968: rules described in this section to generate the DOM trees. Together,
969: these rules define what is referred to as the <dfn id="html-parser">HTML
970: parser</dfn>.</p>
971:
972: <div class="note">
973:
974: <p>While the HTML syntax described in this specification bears a
975: close resemblance to SGML and XML, it is a separate language with
976: its own parsing rules.</p>
977:
1.183 mike 978: <p>Some earlier versions of HTML (in particular from HTML2 to
979: HTML4) were based on SGML and used SGML parsing rules. However, few
1.1 mike 980: (if any) web browsers ever implemented true SGML parsing for HTML
981: documents; the only user agents to strictly handle HTML as an SGML
982: application have historically been validators. The resulting
983: confusion — with validators claiming documents to have one
984: representation while widely deployed Web browsers interoperably
985: implemented a different representation — has wasted decades
986: of productivity. This version of HTML thus returns to a non-SGML
987: basis.</p>
988:
989: <p>Authors interested in using SGML tools in their authoring
990: pipeline are encouraged to use XML tools and the XML serialization
991: of HTML.</p>
992:
993: </div>
994:
995: <p>This specification defines the parsing rules for HTML documents,
996: whether they are syntactically correct or not. Certain points in the
997: parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
998: errors</dfn>. The error handling for parse errors is well-defined:
999: user agents must either act as described below when encountering
1000: such problems, or must abort processing at the first error that they
1001: encounter for which they do not wish to apply the rules described
1002: below.</p>
1003:
1004: <p>Conformance checkers must report at least one parse error
1005: condition to the user if one or more parse error conditions exist in
1006: the document and must not report parse error conditions if none
1007: exist in the document. Conformance checkers may report more than one
1.174 mike 1008: parse error condition if more than one parse error condition exists
1.1 mike 1009: in the document. Conformance checkers are not required to recover
1010: from parse errors.</p>
1011:
1012: <p class="note">Parse errors are only errors with the
1013: <em>syntax</em> of HTML. In addition to checking for parse errors,
1014: conformance checkers will also verify that the document obeys all
1015: the other conformance requirements described in this
1016: specification.</p>
1017:
1018: <p>For the purposes of conformance checkers, if a resource is
1019: determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
1020: <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
1021:
1.266 mike 1022: </div><div class="impl">
1.1 mike 1023:
1.895 mike 1024: <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 1025:
1026: <p>The input to the HTML parsing process consists of a stream of
1027: Unicode characters, which is passed through a
1028: <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
1.810 mike 1029: construction</a> stage. The output is a <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 1030: object.</p>
1031:
1032: <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
1033: support scripting</a> do not have to actually create a DOM
1.810 mike 1034: <code><a href="infrastructure.html#document">Document</a></code> object, but the DOM tree in such cases is
1.1 mike 1035: still used as the model for the rest of the specification.</p>
1036:
1037: <p>In the common case, the data handled by the tokenization stage
1.159 mike 1038: comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
1039: 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 1040:
1.724 mike 1041: <p><img alt="" src="http://dev.w3.org/html5/spec/images/parsing-model-overview.png"></p>
1.1 mike 1042:
1043: <p id="nestedParsing">There is only one set of states for the
1044: tokenizer stage and the tree construction stage, but the tree
1045: construction stage is reentrant, meaning that while the tree
1046: construction stage is handling one token, the tokenizer might be
1047: resumed, causing further tokens to be emitted and processed before
1048: the first token's processing is complete.</p>
1049:
1050: <div class="example">
1051:
1052: <p>In the following example, the tree construction stage will be
1053: called upon to handle a "p" start tag token while handling the
1054: "script" start tag token:</p>
1055:
1056: <pre>...
1057: <script>
1058: document.write('<p>');
1059: </script>
1060: ...</pre>
1061:
1062: </div>
1063:
1064: <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
1065: level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
1066: pause flag</dfn>, which must be initially set to false.</p>
1067:
1.266 mike 1068: </div><div class="impl">
1.1 mike 1069:
1.895 mike 1070: <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 1071:
1072: <p>The stream of Unicode characters that comprises the input to the
1073: tokenization stage will be initially seen by the user agent as a
1074: stream of bytes (typically coming over the network or from the local
1075: file system). The bytes encode the actual characters according to a
1076: particular <em>character encoding</em>, which the user agent must
1077: use to decode the bytes into characters.</p>
1078:
1079: <p class="note">For XML documents, the algorithm user agents must
1080: use to determine the character encoding is given by the XML
1.104 mike 1081: specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1 mike 1082:
1083:
1.895 mike 1084: <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 1085:
1086: <p>In some cases, it might be impractical to unambiguously determine
1087: the encoding before parsing the document. Because of this, this
1088: specification provides for a two-pass mechanism with an optional
1089: pre-scan. Implementations are allowed, as described below, to apply
1090: a simplified parsing algorithm to whatever bytes they have available
1091: before beginning to parse the document. Then, the real parser is
1092: started, using a tentative encoding derived from this pre-parse and
1093: other out-of-band metadata. If, while the document is being loaded,
1094: the user agent discovers an encoding declaration that conflicts with
1095: this information, then the parser can get reinvoked to perform a
1096: parse of the document with the real encoding.</p>
1097:
1098: <p id="documentEncoding">User agents must use the following
1099: algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
1100: the character encoding to use when decoding a document in the first
1101: pass. This algorithm takes as input any out-of-band metadata
1102: available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
1103: and all the bytes available so far, and returns an encoding and a
1104: <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
1105: confidence is either <i>tentative</i>, <i>certain</i>, or
1106: <i>irrelevant</i>. The encoding used, and whether the confidence in
1107: that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
1108: determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
1109: encoding is necessary, e.g. because the parser is operating on a
1110: stream of Unicode characters and doesn't have to use an encoding at
1111: all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
1112: <i>irrelevant</i>.</p>
1113:
1114: <ol><li><p>If the transport layer specifies an encoding, and it is
1115: supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1116: <i>certain</i>, and abort these steps.</p></li>
1117:
1118: <li><p>The user agent may wait for more bytes of the resource to be
1119: available, either in this step or at any later step in this
1120: algorithm. For instance, a user agent might wait 500ms or 512
1121: bytes, whichever came first. In general preparsing the source to
1122: find the encoding improves performance, as it reduces the need to
1123: throw away the data structures used when parsing upon finding the
1124: encoding information. However, if the user agent delays too long to
1125: obtain data to determine the encoding, then the cost of the delay
1126: could outweigh any performance improvements from the
1127: preparse.</p></li>
1128:
1129: <li><p>For each of the rows in the following table, starting with
1130: the first one and going down, if there are as many or more bytes
1131: available than the number of bytes in the first column, and the
1132: first bytes of the file match the bytes given in the first column,
1133: then return the encoding given in the cell in the second column of
1134: that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1135: <i>certain</i>, and abort these steps:</p>
1136:
1137: <!-- this table is present in several forms in this file; keep them in sync -->
1138: <table><thead><tr><th>Bytes in Hexadecimal
1139: </th><th>Encoding
1140: </th></tr></thead><tbody><!-- nobody uses this
1141: <tr>
1142: <td>00 00 FE FF
1143: <td>UTF-32BE
1144: <tr>
1145: <td>FF FE 00 00
1146: <td>UTF-32LE
1147: --><tr><td>FE FF
1148: </td><td>UTF-16BE
1149: </td></tr><tr><td>FF FE
1150: </td><td>UTF-16LE
1151: </td></tr><tr><td>EF BB BF
1152: </td><td>UTF-8
1153: <!-- nobody uses this
1154: <tr>
1155: <td>DD 73 66 73
1156: <td>UTF-EBCDIC
1157: -->
1158: </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
1159: (BOMs).</p></li>
1160:
1161: <li><p>Otherwise, the user agent will have to search for explicit
1162: character encoding information in the file itself. This should
1163: proceed as follows:
1164:
1165: </p><p>Let <var title="">position</var> be a pointer to a byte in the
1166: input stream, initially pointing at the first byte. If at any
1167: point during these substeps the user agent either runs out of
1168: bytes or decides that scanning further bytes would not be
1169: efficient, then skip to the next step of the overall character
1170: encoding detection algorithm. User agents may decide that scanning
1171: <em>any</em> bytes is not efficient, in which case these substeps
1172: are entirely skipped.</p>
1173:
1174: <p>Now, repeat the following "two" steps until the algorithm
1175: aborts (either because user agent aborts, as described above, or
1176: because a character encoding is found):</p>
1177:
1178: <ol><li><p>If <var title="">position</var> points to:</p>
1179:
1180: <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '<!--')</dt>
1181: <dd>
1182:
1183: <p>Advance the <var title="">position</var> pointer so that it
1184: points at the first 0x3E byte which is preceded by two 0x2D
1185: bytes (i.e. at the end of an ASCII '-->' sequence) and comes
1186: after the 0x3C byte that was found. (The two 0x2D bytes can be
1187: the same as the those in the '<!--' sequence.)</p>
1188:
1189: </dd>
1190:
1191: <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>
1192: <dd>
1193:
1194: <ol><li><p>Advance the <var title="">position</var> pointer so
1195: that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
1196: 0x2F byte (the one in sequence of characters matched
1197: above).</p></li>
1198:
1.923 mike 1199: <li><p>Let <var title="">attribute list</var> be an empty
1200: list of strings.</p></li> <!-- so long as we only care about
1201: http-equiv, content, and charset, this can be a 3-bit
1202: bitfield -->
1203:
1204: <li><p>Let <var title="">got pragma</var> be false.</p></li>
1205:
1206: <li><p>Let <var title="">mode</var> be null.</p></li>
1207:
1208: <li><p>Let <var title="">charset</var> be the null value
1209: (which, for the purposes of this algorithm, is distinct from
1210: an unrecognised encoding or the empty string).</p></li>
1211:
1212: <li><p><i>Attributes</i>: <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get an
1213: attribute</a> and its value. If no attribute was sniffed,
1214: then jump to the <i>processing</i> step below.</p></li>
1215:
1216: <li><p>If the attribute's name is already in <var title="">attribute list</var>, then return to the step
1217: labeled <i>attributes</i>.</p>
1218:
1219: </li><li>
1220:
1221: <p>Run the appropriate step from the following list, if one
1222: applies:</p>
1223:
1224: <dl class="switch"><dt>If the attribute's name is "<code title="">http-equiv</code>"</dt>
1225:
1226: <dd><p>If the attribute's value is "<code title="">content-type</code>", then set <var title="">got
1227: pragma</var> to true.</p></dd>
1228:
1229: <dt>If the attribute's name is "<code title="">charset</code>"</dt>
1230:
1231: <dd><p>If <var title="">charset</var> is still set to null,
1232: let <var title="">charset</var> be the encoding
1233: corresponding to the attribute's value, and set <var title="">mode</var> to "charset".</p></dd>
1234:
1235: <dt>If the attribute's name is "<code title="">content</code>"</dt>
1236:
1237: <dd><p>Apply the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding
1238: from a Content-Type</a>, giving the attribute's value as
1239: the string to parse. If an encoding is returned, and if
1240: <var title="">charset</var> is still set to null, let <var title="">charset</var> be the encoding returned, and set
1241: <var title="">mode</var> to "pragma".</p></dd>
1242:
1243: </dl></li>
1244:
1245: <li><p>Return to the step labeled <i>attributes</i>.</p></li>
1246:
1247: <li><p><i>Processing</i>: If <var title="">mode</var> is
1248: null, then jump to the second step of the overall "two step"
1249: algorithm.</p></li>
1250:
1251: <li><p>If <var title="">mode</var> is "pragma" but <var title="">got pragma</var> is false, then jump to the second
1252: step of the overall "two step" algorithm.</p></li>
1.1 mike 1253:
1254: <li><p>If <var title="">charset</var> is a UTF-16 encoding,
1255: change the value of <var title="">charset</var> to
1256: UTF-8.</p></li>
1257:
1.923 mike 1258: <li><p>If <var title="">charset</var> is not a supported
1259: character encoding, then jump to the second step of the
1260: overall "two step" algorithm.</p></li>
1261:
1262: <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 1263: <i>tentative</i>, and abort all these steps.</p></li>
1264:
1265: </ol></dd>
1266:
1.464 mike 1267: <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 1268: <dd>
1269:
1270: <ol><li><p>Advance the <var title="">position</var> pointer so
1271: that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
1272: 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464 mike 1273: (ASCII >) byte.</p></li>
1.1 mike 1274:
1275: <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
1276: attribute</a> until no further attributes can be found,
1277: then jump to the second step in the overall "two step"
1278: algorithm.</p></li>
1279:
1280: </ol></dd>
1281:
1282: <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '<!')</dt>
1283: <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '</')</dt>
1284: <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '<?')</dt>
1285: <dd>
1286:
1287: <p>Advance the <var title="">position</var> pointer so that it
1.464 mike 1288: points at the first 0x3E byte (ASCII >) that comes after the
1.1 mike 1289: 0x3C byte that was found.</p>
1290:
1291: </dd>
1292:
1293: <dt>Any other byte</dt>
1294: <dd>
1295:
1296: <p>Do nothing with that byte.</p>
1297:
1298: </dd>
1299:
1300: </dl></li>
1301:
1302: <li>Move <var title="">position</var> so it points at the next
1303: byte in the input stream, and return to the first step of this
1304: "two step" algorithm.</li>
1305:
1306: </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
1307: attribute</dfn>, it means doing this:</p>
1308:
1309: <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
1310: (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464 mike 1311: 0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1 mike 1312: substep.</p></li>
1313:
1314: <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464 mike 1315: >), then abort the "get an attribute" algorithm. There isn't
1.1 mike 1316: one.</p></li>
1317:
1318: <li><p>Otherwise, the byte at <var title="">position</var> is the
1319: start of the attribute name. Let <var title="">attribute
1320: name</var> and <var title="">attribute value</var> be the empty
1321: string.</p></li>
1322:
1323: <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
1324:
1.464 mike 1325: <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1 mike 1326: name</var> is longer than the empty string</dt>
1327:
1328: <dd>Advance <var title="">position</var> to the next byte and
1329: jump to the step below labeled <i>value</i>.</dd>
1330:
1331: <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1332: FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
1333:
1334: <dd>Jump to the step below labeled <i>spaces</i>.</dd>
1335:
1.464 mike 1336: <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII >)</dt>
1.1 mike 1337:
1338: <dd>Abort the "get an attribute" algorithm. The attribute's
1339: name is the value of <var title="">attribute name</var>, its
1340: value is the empty string.</dd>
1341:
1.464 mike 1342: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1343: Z)</dt>
1.1 mike 1344:
1345: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1346: name</var> (where <var title="">b</var> is the value of the
1347: byte at <var title="">position</var>).</dd>
1348:
1349: <dt>Anything else</dt>
1350:
1351: <dd>Append the Unicode character with the same code point as the
1352: value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
1353: bytes outside the ASCII range are handled here, since only
1354: ASCII characters can contribute to the detection of a character
1355: encoding.)</dd>
1356:
1357: </dl></li>
1358:
1359: <li><p>Advance <var title="">position</var> to the next byte and
1360: return to the previous step.</p></li>
1361:
1362: <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1363: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1364: advance <var title="">position</var> to the next byte, then,
1365: repeat this step.</p></li>
1366:
1367: <li><p>If the byte at <var title="">position</var> is
1.464 mike 1368: <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1 mike 1369: algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
1370: string.</p></li>
1371:
1372: <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464 mike 1373: =) byte.</p></li>
1.1 mike 1374:
1.916 mike 1375: <li><p><i>Value</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1.1 mike 1376: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1377: advance <var title="">position</var> to the next byte, then,
1378: repeat this step.</p></li>
1379:
1380: <li><p>Process the byte at <var title="">position</var> as
1381: follows:</p>
1382:
1.464 mike 1383: <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1 mike 1384:
1385: <dd>
1386:
1387: <ol><li>Let <var title="">b</var> be the value of the byte at
1388: <var title="">position</var>.</li>
1389:
1390: <li>Advance <var title="">position</var> to the next
1391: byte.</li>
1392:
1393: <li>If the value of the byte at <var title="">position</var>
1394: is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
1395: an attribute" algorithm. The attribute's name is the value of
1396: <var title="">attribute name</var>, and its value is the
1397: value of <var title="">attribute value</var>.</li>
1398:
1.464 mike 1399: <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
1400: 0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1 mike 1401: than the value of the byte at <var title="">position</var>.</li>
1402:
1403: <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
1404: the value of the byte at <var title="">position</var>.</li>
1405:
1406: <li>Return to the second step in these substeps.</li>
1407:
1408: </ol></dd>
1409:
1.464 mike 1410: <dt>If it is 0x3E (ASCII >)</dt>
1.1 mike 1411:
1412: <dd>Abort the "get an attribute" algorithm. The attribute's
1413: name is the value of <var title="">attribute name</var>, its
1414: value is the empty string.</dd>
1415:
1416:
1.464 mike 1417: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1418: Z)</dt>
1.1 mike 1419:
1420: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1421: value</var> (where <var title="">b</var> is the value of the
1422: byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
1423:
1424: <dt>Anything else</dt>
1425:
1426: <dd>Append the Unicode character with the same code point as the
1427: 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>
1428:
1429: </dl></li>
1430:
1431: <li><p>Process the byte at <var title="">position</var> as
1432: follows:</p>
1433:
1434: <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1435: FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464 mike 1436: >)</dt>
1.1 mike 1437:
1438: <dd>Abort the "get an attribute" algorithm. The attribute's
1439: name is the value of <var title="">attribute name</var> and its
1440: value is the value of <var title="">attribute value</var>.</dd>
1441:
1.464 mike 1442: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1443: Z)</dt>
1.1 mike 1444:
1445: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1446: value</var> (where <var title="">b</var> is the value of the
1447: byte at <var title="">position</var>).</dd>
1448:
1449: <dt>Anything else</dt>
1450:
1451: <dd>Append the Unicode character with the same code point as the
1452: value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
1453:
1454: </dl></li>
1455:
1456: <li><p>Advance <var title="">position</var> to the next byte and
1457: return to the previous step.</p></li>
1458:
1459: </ol><p>For the sake of interoperability, user agents should not use a
1460: pre-scan algorithm that returns different results than the one
1461: described above. (But, if you do, please at least let us know, so
1462: that we can improve this algorithm and benefit everyone...)</p>
1463:
1464: </li>
1465:
1466: <li><p>If the user agent has information on the likely encoding for
1467: this page, e.g. based on the encoding of the page when it was last
1468: visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1469: <i>tentative</i>, and abort these steps.</p></li>
1470:
1.322 mike 1471: <li>
1472:
1473: <p>The user agent may attempt to autodetect the character encoding
1474: from applying frequency analysis or other algorithms to the data
1.568 mike 1475: stream. Such algorithms may use information about the resource
1476: other than the resource's contents, including the address of the
1477: resource. If autodetection succeeds in determining a character
1.322 mike 1478: encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1479: <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
1480:
1481: <p class="note">The UTF-8 encoding has a highly detectable bit
1482: pattern. Documents that contain bytes with values greater than
1483: 0x7F which match the UTF-8 pattern are very likely to be UTF-8,
1484: while documents with byte sequences that do not match it are very
1485: likely not. User-agents are therefore encouraged to search for
1.485 mike 1486: this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322 mike 1487:
1488: </li>
1.1 mike 1489:
1.501 mike 1490: <li>
1491:
1492: <p>Otherwise, return an implementation-defined or user-specified
1493: default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1494: <i>tentative</i>.</p>
1495:
1496: <p>In controlled environments or in environments where the
1497: encoding of documents can be prescribed (for example, for user
1498: agents intended for dedicated use in new networks), the
1499: comprehensive <code title="">UTF-8</code> encoding is
1500: suggested.</p>
1501:
1502: <p>In other environments, the default encoding is typically
1503: dependent on the user's locale (an approximation of the languages,
1.760 mike 1504: and thus often encodings, of the pages that the user is likely to
1505: frequent). The following table gives suggested defaults based on
1506: the user's locale, for compatibility with legacy content. Locales
1.934 mike 1507: are identified by BCP 47 language tags. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501 mike 1508:
1.920 mike 1509: <!-- based on mozilla 1.9.1 localizations:
1.501 mike 1510: http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
1511:
1.504 mike 1512: <table><thead><tr><th>Locale language
1.501 mike 1513: </th><th>Suggested default encoding
1514: </th></tr></thead><tbody><tr><td>ar
1515: </td><td>UTF-8
1516:
1517: </td></tr><tr><td>be
1518: </td><td>ISO-8859-5
1519:
1520: </td></tr><tr><td>bg
1521: </td><td>windows-1251
1522:
1523: </td></tr><tr><td>cs<!-- -CZ -->
1524: </td><td>ISO-8859-2
1525:
1526: </td></tr><tr><td>cy
1527: </td><td>UTF-8
1528:
1529: </td></tr><tr><td>fa<!-- -IR -->
1530: </td><td>UTF-8
1531:
1532: </td></tr><tr><td>he<!-- -IL -->
1533: </td><td>windows-1255
1534:
1535: </td></tr><tr><td>hr
1536: </td><td>UTF-8
1537:
1538: </td></tr><tr><td>hu<!-- -HU -->
1539: </td><td>ISO-8859-2
1540:
1541: </td></tr><tr><td>ja <!-- and ja-JP-mac -->
1.863 mike 1542: </td><td>Windows-31J <!-- Shift_JIS -->
1.501 mike 1543:
1544: </td></tr><tr><td>kk
1545: </td><td>UTF-8
1546:
1547: </td></tr><tr><td>ko<!-- -KR -->
1548: </td><td>windows-949 <!-- EUC-KR -->
1549:
1550: </td></tr><tr><td>ku
1551: </td><td>windows-1254 <!-- ISO-8859-9 -->
1552:
1553: </td></tr><tr><td>lt
1554: </td><td>windows-1257
1555:
1556: </td></tr><tr><td>lv<!-- -LV -->
1557: </td><td>ISO-8859-13
1558:
1559: </td></tr><tr><td>mk<!-- -MK -->
1560: </td><td>UTF-8
1561:
1562: </td></tr><tr><td>or
1563: </td><td>UTF-8
1564:
1565: </td></tr><tr><td>pl<!-- -PL -->
1566: </td><td>ISO-8859-2
1567:
1568: </td></tr><tr><td>ro
1569: </td><td>UTF-8
1570:
1571: </td></tr><tr><td>ru
1572: </td><td>windows-1251
1573:
1574: </td></tr><tr><td>sk
1575: </td><td>windows-1250
1576:
1577: </td></tr><tr><td>sl
1578: </td><td>ISO-8859-2
1579:
1580: </td></tr><tr><td>sr
1581: </td><td>UTF-8
1582:
1583: </td></tr><tr><td>th
1584: </td><td>windows-874 <!-- TIS-620 -->
1585:
1586: </td></tr><tr><td>tr<!-- -TR -->
1587: </td><td>windows-1254 <!-- ISO-8859-9 -->
1588:
1.503 mike 1589: </td></tr><tr><td>uk
1.501 mike 1590: </td><td>windows-1251
1591:
1592: </td></tr><tr><td>vi
1593: </td><td>UTF-8
1594:
1595: </td></tr><tr><td>zh-CN
1596: </td><td>GB18030
1597:
1598: </td></tr><tr><td>zh-TW
1599: </td><td>Big5
1600:
1601: </td></tr><tr><td>All other locales
1602: </td><td>windows-1252
1603:
1604: </td></tr></tbody></table></li>
1.1 mike 1605:
1606: </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
1607: be set to the value returned from this algorithm, at the same time
1608: as the user agent uses the returned value to select the decoder to
1609: use for the input stream.</p>
1610:
1.582 mike 1611: <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
1612: of the HTTP specification, which requires that the encoding be
1613: assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1.647 mike 1614: encoding declaration</a> to the contrary, and of RFC 2046,
1.582 mike 1615: which requires that the encoding be assumed to be US-ASCII in the
1616: absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
1617: contrary. This specification's third approach is motivated by a
1618: desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
1619:
1.1 mike 1620:
1.895 mike 1621: <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 1622:
1.237 mike 1623: <p>User agents must at a minimum support the UTF-8 and Windows-1252
1624: encodings, but may support more.</p>
1625:
1626: <p class="note">It is not unusual for Web browsers to support dozens
1627: if not upwards of a hundred distinct character encodings.</p>
1628:
1.365 mike 1629: <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
1630: every character encoding they support, and should support all the
1631: IANA-registered names and aliases of every character encoding they
1632: support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237 mike 1633:
1634: <p>When comparing a string specifying a character encoding with the
1635: name or alias of a character encoding to determine if they are
1636: 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
1637: then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1638: case-insensitive</a> manner.</p>
1639:
1.539 mike 1640: <hr><p>When a user agent would otherwise use an encoding given in the
1.237 mike 1641: first column of the following table to either convert content to
1642: Unicode characters or convert Unicode characters to bytes, it must
1643: instead use the encoding given in the cell in the second column of
1644: the same row. When a byte or sequence of bytes is treated
1645: differently due to this encoding aliasing, it is said to have been
1646: <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
1647:
1648: <table><caption>Character encoding overrides</caption>
1649: <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
1650: </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
1651: <a href="references.html#refsEUCKR">[EUCKR]</a>
1652: <a href="references.html#refsWIN949">[WIN949]</a>
1653: </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
1654: <a href="references.html#refsRFC1345">[RFC1345]</a>
1655: <a href="references.html#refsGBK">[GBK]</a>
1656: </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
1657: <a href="references.html#refsRFC1345">[RFC1345]</a>
1658: <a href="references.html#refsGBK">[GBK]</a>
1659: </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
1660: <a href="references.html#refsRFC1345">[RFC1345]</a>
1661: <a href="references.html#refsWIN1252">[WIN1252]</a>
1662: </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
1663: <a href="references.html#refsRFC1345">[RFC1345]</a>
1664: <a href="references.html#refsWIN1254">[WIN1254]</a>
1665: </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
1666: <a href="references.html#refsISO885911">[ISO885911]</a>
1667: <a href="references.html#refsWIN874">[WIN874]</a>
1668: </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
1669: <a href="references.html#refsRFC1345">[RFC1345]</a>
1670: <a href="references.html#refsWIN949">[WIN949]</a>
1.863 mike 1671: </td></tr><tr><td> Shift_JIS </td><td> Windows-31J </td><td>
1.237 mike 1672: <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
1673: <a href="references.html#refsWIN31J">[WIN31J]</a>
1674: </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
1675: <a href="references.html#refsTIS620">[TIS620]</a>
1676: <a href="references.html#refsWIN874">[WIN874]</a>
1677: </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
1678: <a href="references.html#refsRFC1345">[RFC1345]</a>
1679: <a href="references.html#refsWIN1252">[WIN1252]</a>
1680: </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
1681: encodings according to the table above is a <a href="introduction.html#willful-violation">willful
1682: violation</a> of the W3C Character Model specification, motivated
1683: by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
1684:
1685: <p>When a user agent is to use the UTF-16 encoding but no BOM has
1686: been found, user agents must default to UTF-16LE.</p>
1687:
1688: <p class="note">The requirement to default UTF-16 to LE rather than
1689: BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581 mike 1690: desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237 mike 1691:
1692: <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
1693: 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>
1694:
1695: <p>Support for encodings based on EBCDIC is not recommended. This
1696: encoding is rarely used for publicly-facing Web content.</p>
1697:
1698: <p>Support for UTF-32 is not recommended. This encoding is rarely
1699: used, and frequently implemented incorrectly.</p>
1700:
1701: <p class="note">This specification does not make any attempt to
1702: support EBCDIC-based encodings and UTF-32 in its algorithms; support
1703: and use of these encodings can thus lead to unexpected behavior in
1704: implementations of this specification.</p>
1705:
1706:
1707:
1.895 mike 1708: <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 1709:
1710: <p>Given an encoding, the bytes in the input stream must be
1711: converted to Unicode characters for the tokenizer, as described by
1712: the rules for that encoding, except that the leading U+FEFF BYTE
1713: ORDER MARK character, if any, must not be stripped by the encoding
1714: layer (it is stripped by the rule below).</p> <!-- this is to
1715: prevent two leading BOMs from being both stripped, once by the
1716: decoder, and once by the parser -->
1717:
1718: <p>Bytes or sequences of bytes in the original byte stream that
1.393 mike 1719: could not be converted to Unicode code points must be converted to
1720: U+FFFD REPLACEMENT CHARACTERs.</p>
1.1 mike 1721:
1722: <p class="note">Bytes or sequences of bytes in the original byte
1723: stream that did not conform to the encoding specification
1724: (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
1725: errors that conformance checkers are expected to report.</p>
1726:
1.438 mike 1727: <p>Any byte or sequence of bytes in the original byte stream that is
1728: <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1 mike 1729: error</a>.</p>
1730:
1731: <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
1732: any are present.</p>
1733:
1.300 mike 1734: <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
1735: character regardless of whether that character was used to determine
1736: the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
1737: motivated by a desire to increase the resilience of user agents in
1738: the face of naïve transcoders.</p>
1739:
1.316 mike 1740: <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315 mike 1741: U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
1742: them to suddenly turn into codepoints when they go through a UTF-16
1743: pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316 mike 1744: CHARACTERs. Any occurrences of such characters and code points are
1745: <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1 mike 1746:
1747: <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
1748: <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
1749: CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315 mike 1750: <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
1751: to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
1752: U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
1753: U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
1754: U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
1755: U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
1756: U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316 mike 1757: errors</a>. These are all control characters or permanently
1758: undefined Unicode characters (noncharacters).</p>
1.1 mike 1759:
1760: <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
1761: characters are treated specially. Any CR characters that are
1762: followed by LF characters must be removed, and any CR characters not
1763: followed by LF characters must be converted to LF characters. Thus,
1764: newlines in HTML DOMs are represented by LF characters, and there
1765: are never any CR characters in the input to the
1766: <a href="#tokenization">tokenization</a> stage.</p>
1767:
1768: <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
1769: input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
1770: the <i><a href="#next-input-character">next input character</a></i> is the first character in the
1771: input. The <dfn id="current-input-character">current input character</dfn> is the last character
1772: to have been <i><a href="#consumed">consumed</a></i>.</p>
1773:
1774: <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
1775: character or just before the end of the input stream) where content
1.159 mike 1776: 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 1777: inserted. The insertion point is relative to the position of the
1778: character immediately after it, it is not an absolute offset into
1779: the input stream. Initially, the insertion point is
1.10 mike 1780: undefined.</p>
1.1 mike 1781:
1782: <p>The "EOF" character in the tables below is a conceptual character
1783: representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159 mike 1784: is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1 mike 1785: <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159 mike 1786: 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 1787: consumed. Otherwise, the "EOF" character is not a real character in
1788: the stream, but rather the lack of any further characters.</p>
1789:
1790:
1.895 mike 1791: <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 1792:
1793: <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
1794: encoding</dfn>, it must run the following steps. This might happen
1795: if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
1796: failed to find an encoding, or if it found an encoding that was not
1797: the actual encoding of the file.</p>
1798:
1799: <ol><li>If the new encoding is identical or equivalent to the encoding
1800: that is already being used to interpret the input stream, then set
1801: the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1802: <i>certain</i> and abort these steps. This happens when the
1803: encoding information found in the file matches what the
1804: <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
1805: encoding, and in the second pass through the parser if the first
1806: pass found that the encoding sniffing algorithm described in the
1807: earlier section failed to find the right encoding.</li>
1808:
1809: <li>If the encoding that is already being used to interpret the
1810: input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1811: <i>certain</i> and abort these steps. The new encoding is ignored;
1812: if it was anything but the same encoding, then it would be clearly
1813: incorrect.</li>
1814:
1815: <li>If the new encoding is a UTF-16 encoding, change it to
1816: UTF-8.</li>
1817:
1818: <li>If all the bytes up to the last byte converted by the current
1819: decoder have the same Unicode interpretations in both the current
1820: encoding and the new encoding, and if the user agent supports
1821: changing the converter on the fly, then the user agent may change
1822: to the new converter for the encoding on the fly. Set the
1823: <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
1824: convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1825: <i>certain</i>, and abort these steps.</li>
1826:
1827: <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
1828: <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
1829: browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
1830: sniffing algorithm</a> and instead just set the encoding to the
1831: new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1832: <i>certain</i>. Whenever possible, this should be done without
1833: actually contacting the network layer (the bytes should be
1834: re-parsed from memory), even if, e.g., the document is marked as
1835: not being cacheable. If this is not possible and contacting the
1836: network layer would involve repeating a request that uses a method
1837: other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
1838: equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1839: <i>certain</i> and ignore the new encoding. The resource will be
1840: misinterpreted. User agents may notify the user of the situation,
1841: to aid in application development.</li>
1842:
1.266 mike 1843: </ol></div><div class="impl">
1844:
1.895 mike 1845: <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 1846:
1.895 mike 1847: <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 1848:
1849: <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
1850: the primary operation of the tree construction stage.</p>
1851:
1852: <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
1853: "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
1854: "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
1855: "<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 1856: "<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 1857: "<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>",
1858: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
1859: "<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
1860: table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
1861: foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
1862: body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
1863: frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
1864: frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
1865: after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
1866: frameset</a>" during the course of the parsing, as described in
1867: the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
1868: how tokens are processed and whether CDATA sections are
1869: supported.</p>
1870:
1871: <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
1872: head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
1873: body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
1874: table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
1875: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
1876: "<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
1877: that the other modes defer to them at various times. When the
1878: algorithm below says that the user agent is to do something
1879: "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
1880: mode", where <var title="">m</var> is one of these modes, the user
1881: agent must use the rules described under the <var title="">m</var>
1882: <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
1883: <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>
1884: to a new value.</p>
1885:
1886: <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540 mike 1887: mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
1888: text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
1889: is also set. This is the insertion mode to which the tree
1890: construction stage will return.</p>
1.1 mike 1891:
1892: <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
1893: mode: in foreign content">in foreign content</a>", the
1894: <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
1895: is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
1896: foreign content">in foreign content</a>" mode to handle HTML
1897: (i.e. not foreign) content.</p>
1898:
1899: <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
1900: mode appropriately</dfn>, it means the UA must follow these
1901: steps:</p>
1902:
1903: <ol><li>Let <var title="">last</var> be false.</li>
1904:
1.604 mike 1905: <li>Let <var title="">foreign</var> be false.</li>
1906:
1.1 mike 1907: <li>Let <var title="">node</var> be the last node in the
1908: <a href="#stack-of-open-elements">stack of open elements</a>.</li>
1909:
1.604 mike 1910: <li><i>Loop</i>: If <var title="">node</var> is the first node in
1911: the stack of open elements, then set <var title="">last</var> to
1912: 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 1913:
1914: <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604 mike 1915: 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 1916: step labeled <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1 mike 1917:
1918: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
1919: <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
1920: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.856 mike 1921: mode: in cell">in cell</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1 mike 1922:
1923: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
1924: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.856 mike 1925: mode: in row">in row</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1 mike 1926:
1927: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
1928: <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
1929: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.856 mike 1930: table body">in table body</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1 mike 1931:
1932: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604 mike 1933: 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 1934: the step labeled <i title="">end</i>.</li>
1.1 mike 1935:
1936: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
1937: 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 1938: jump to the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604 mike 1939: case</a>)</li>
1.1 mike 1940:
1941: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604 mike 1942: 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 1943: step labeled <i title="">end</i>.</li>
1.1 mike 1944:
1.159 mike 1945: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604 mike 1946: 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 1947: the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604 mike 1948: case</a>)</li> <!-- This is only here for now in case people
1949: think that the spec accidentally omitted it and try to "fix"
1950: it. Note that noscript-in-head is also handled this way. This is
1951: all intentional. The only thing it doesn't handle is the
1952: scripting-disabled fragment parsing case for a <head> element
1953: containing a <noscript> which itself contains something other than
1.872 mike 1954: a <link> or a <style type="text/css"> element; you'd expect that to break out of
1.604 mike 1955: the <noscript> but it doesn't. This is an edge case that doesn't
1956: affect the spec, since the algorithm for fragment parsing is only
1957: used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
1958: scripting is enabled. -->
1.1 mike 1959:
1.159 mike 1960: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604 mike 1961: 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 1962: step labeled <i title="">end</i>.</li>
1.1 mike 1963:
1.5 mike 1964: <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604 mike 1965: 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 1966: the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604 mike 1967: case</a>)</li>
1.1 mike 1968:
1.159 mike 1969: <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333 mike 1970: then <!--: if the <span><code title="">head</code> element
1971: pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
1972: to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
1973: head</a>"<!--, otherwise, switch the <span>insertion mode</span>
1974: to "<span title="insertion mode: after head">after head</span>".-->
1.856 mike 1975: 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 1976: head element pointer can ever be non-null when we're going through
1977: these steps, we'll need to uncomment out the commented-out bits -->
1978:
1.724 mike 1979: <li>If <var title="">node</var> is an element from the <a href="infrastructure.html#mathml-namespace">MathML
1980: namespace</a> or the <a href="infrastructure.html#svg-namespace">SVG namespace</a>, then set the
1.604 mike 1981: <var title="">foreign</var> flag to true.</li>
1.1 mike 1982:
1983: <li>If <var title="">last</var> is true, then switch the
1984: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.856 mike 1985: 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 1986:
1987: <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
1988: elements</a>.</li>
1989:
1.856 mike 1990: <li>Return to the step labeled <i>loop</i>.</li>
1.604 mike 1991:
1992: <li><i>End</i>: If <var title="">foreign</var> is true, switch the
1993: <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
1994: <a href="#insertion-mode">insertion mode</a> is set to, and switch the
1995: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
1996: foreign content">in foreign content</a>".</li>
1.1 mike 1997:
1.895 mike 1998: </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 1999:
2000: <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
2001: stack grows downwards; the topmost node on the stack is the first
2002: one added to the stack, and the bottommost node of the stack is the
2003: most recently added node in the stack (notwithstanding when the
2004: stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
2005:
2006: <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
2007: html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159 mike 2008: <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1 mike 2009: stack.</p>
2010:
2011: <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159 mike 2012: elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1 mike 2013: element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
2014: parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
2015: case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
2016: html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
2017:
1.159 mike 2018: <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 2019: node of the stack. It only gets popped off the stack when the parser
2020: <a href="#stop-parsing" title="stop parsing">finishes</a>.</p>
1.1 mike 2021:
2022: <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
2023: stack.</p>
2024:
2025: <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
2026: element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
2027: 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
2028: open elements</a> (<a href="#fragment-case">fragment case</a>), then the
2029: <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159 mike 2030: of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1 mike 2031:
2032: <p>Elements in the stack fall into the following categories:</p>
2033:
2034: <dl><dt><dfn id="special">Special</dfn></dt>
2035: <dd><p>The following HTML elements have varying levels of special
2036: 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>,
2037: <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 2038: <code><a href="obsolete.html#basefont">basefont</a></code>, <code><a href="obsolete.html#bgsound">bgsound</a></code>,
1.893 mike 2039: <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 2040: <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>,
2041: <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code>, <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID
2042: <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>,
2043: <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>,
2044: <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>,
2045: <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>,
2046: <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>,
2047: <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>,
2048: <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>,
2049: <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>, <!--
2050: <code>image</code>, (commented out because this isn't an element
2051: that can end up on the stack, so it doesn't matter) -->
2052: <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>,
2053: <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>,
2054: <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>,
2055: <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>,
2056: <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>,
2057: <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>,
2058: <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>,
2059: <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>,
2060: <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>,
2061: <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 2062:
2063: <dt><dfn id="scoping">Scoping</dfn></dt>
2064: <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
2065: an element in scope">scopes</a> for various parts of the
1.953 mike 2066: parsing: <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="tabular-data.html#the-caption-element">caption</a></code>,
2067: <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>,
2068: <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
2069: <code>foreignObject</code>.</p></dd>
1.1 mike 2070:
2071: <dt><dfn id="formatting">Formatting</dfn></dt>
2072: <dd><p>The following HTML elements are those that end up in the
2073: <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 2074: <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>,
2075: <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 2076: <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 2077: <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
2078: <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1 mike 2079:
2080: <dt><dfn id="phrasing">Phrasing</dfn></dt>
2081: <dd><p>All other elements found while parsing an HTML
2082: document.</p></dd>
2083:
1.234 mike 2084: </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
2085: specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
2086: match state:</p>
1.1 mike 2087:
2088: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
2089: node</a> (the bottommost node of the stack).</p></li>
2090:
2091: <li><p>If <var title="">node</var> is the target node, terminate in
2092: a match state.</p></li>
2093:
1.234 mike 2094: <li><p>Otherwise, if <var title="">node</var> is one of the element
2095: types in <var title="">list</var>, terminate in a failure
2096: state.</p></li>
1.1 mike 2097:
2098: <li><p>Otherwise, set <var title="">node</var> to the previous
2099: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
2100: 2. (This will never fail, since the loop will always terminate in
2101: the previous step if the top of the stack — an
1.159 mike 2102: <code><a href="semantics.html#the-html-element-0">html</a></code> element — is reached.)</p></li>
1.1 mike 2103:
1.234 mike 2104: </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
2105: it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
2106: of the following element types:</p>
2107:
2108: <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
2109: <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
2110: <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.) -->
2111: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
2112: <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
2113: <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
2114: <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
2115: <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
2116: <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
2117: <li><code title="">foreignObject</code> in the SVG namespace</li>
2118: </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
2119: item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
2120: scope</a> consisting of the following element types:</p>
2121:
2122: <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
2123: in scope</a></i> algorithm.</li>
2124: <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
2125: <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
2126: </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
2127: scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
2128: scope</a> consisting of the following element types:</p>
2129:
2130: <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.) -->
2131: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
2132: </ul><p>Nothing happens if at any time any of the elements in the
1.1 mike 2133: <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
1.810 mike 2134: or removed from, the <code><a href="infrastructure.html#document">Document</a></code> tree. In particular, the
1.1 mike 2135: stack is not changed in this situation. This can cause, amongst
2136: other strange effects, content to be appended to nodes that are no
2137: longer in the DOM.</p>
2138:
2139: <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
2140: the stack is manipulated in a random-access fashion.</p>
2141:
2142:
1.895 mike 2143: <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 2144:
2145: <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
2146: empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
2147:
2148: <p>The list contains elements in the <a href="#formatting">formatting</a>
2149: category, and scope markers. The scope markers are inserted when
1.159 mike 2150: 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 2151: elements, marquees, table cells, and table captions, and are used to
1.5 mike 2152: prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159 mike 2153: elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1 mike 2154: tables.</p>
2155:
2156: <p class="note">The scope markers are unrelated to the concept of an
2157: element being <a href="#has-an-element-in-scope" title="has an element in scope">in
2158: scope</a>.</p>
2159:
2160: <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
2161: elements</a> is associated with the token for which it was
2162: created, so that further elements can be created for that token if
2163: necessary.</p>
2164:
2165: <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
2166: active formatting elements</dfn>, the UA must perform the following
2167: steps:</p>
2168:
2169: <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
2170: elements</a>, then there is nothing to reconstruct; stop this
2171: algorithm.</li>
2172:
2173: <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
2174: active formatting elements</a> is a marker, or if it is an
2175: element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
2176: there is nothing to reconstruct; stop this algorithm.</li>
2177:
2178: <li>Let <var title="">entry</var> be the last (most recently added)
2179: element in the <a href="#list-of-active-formatting-elements">list of active formatting
2180: elements</a>.</li>
2181:
2182: <li>If there are no entries before <var title="">entry</var> in the
2183: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
2184: 8.</li>
2185:
2186: <li>Let <var title="">entry</var> be the entry one earlier than
2187: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2188: elements</a>.</li>
2189:
2190: <li>If <var title="">entry</var> is neither a marker nor an element
2191: that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
2192: 4.</li>
2193:
2194: <li>Let <var title="">entry</var> be the element one later than
2195: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2196: elements</a>.</li>
2197:
2198: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
2199: element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
2200:
2201: <li>Append <var title="">new element</var> to the <a href="#current-node">current
2202: node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
2203: elements</a> so that it is the new <a href="#current-node">current
2204: node</a>.</li>
2205:
2206: <li>Replace the entry for <var title="">entry</var> in the list
2207: with an entry for <var title="">new element</var>.</li>
2208:
2209: <li>If the entry for <var title="">new element</var> in the
2210: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
2211: entry in the list, return to step 7.</li>
2212:
2213: </ol><p>This has the effect of reopening all the formatting elements that
2214: were opened in the current body, cell, or caption (whichever is
2215: youngest) that haven't been explicitly closed.</p>
2216:
2217: <p class="note">The way this specification is written, the
2218: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
2219: elements in chronological order with the least recently added
2220: element first and the most recently added element last (except for
2221: while steps 8 to 11 of the above algorithm are being executed, of
2222: course).</p>
2223:
2224: <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
2225: active formatting elements up to the last marker</dfn>, the UA must
2226: perform the following steps:</p>
2227:
2228: <ol><li>Let <var title="">entry</var> be the last (most recently added)
2229: entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
2230:
2231: <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
2232: formatting elements</a>.</li>
2233:
2234: <li>If <var title="">entry</var> was a marker, then stop the
2235: algorithm at this point. The list has been cleared up to the last
2236: marker.</li>
2237:
2238: <li>Go to step 1.</li>
2239:
1.895 mike 2240: </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 2241:
2242: <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
2243: pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
2244: pointer</dfn> are both null.</p>
2245:
1.159 mike 2246: <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1 mike 2247: implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
2248: element pointer</a> gets set to point to this node.</p>
2249:
2250: <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
2251: points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
2252: whose end tag has not yet been seen. It is used to make form
2253: controls associate with forms in the face of dramatically bad
2254: markup, for historical reasons.</p>
2255:
2256:
1.895 mike 2257: <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 2258:
1.794 mike 2259: <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 2260: <code><a href="infrastructure.html#document">Document</a></code> with which the parser is associated when the
1.1 mike 2261: parser was created, and "disabled" otherwise.</p>
2262:
2263: <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
2264: when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
2265: parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
2266: don't execute in that case.</p>
2267:
2268: <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
2269: created. It is set to "not ok" after certain tokens are seen.</p>
2270:
1.266 mike 2271: </div><div class="impl">
1.1 mike 2272:
1.895 mike 2273: <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 2274:
2275: <p>Implementations must act as if they used the following state
2276: machine to tokenize HTML. The state machine must start in the
2277: <a href="#data-state">data state</a>. Most states consume a single character,
2278: which may have various side-effects, and either switches the state
2279: machine to a new state to <em>reconsume</em> the same character, or
2280: switches it to a new state (to consume the next character), or
2281: repeats the same state (to consume the next character). Some states
2282: have more complicated behavior and can consume several characters
1.541 mike 2283: before switching to another state. In some cases, the tokenizer
2284: state is also changed by the tree construction stage.</p>
1.1 mike 2285:
1.541 mike 2286: <p>The exact behavior of certain states depends on the
2287: <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
2288: elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
2289: buffer</var></dfn> to track progress.</p>
1.1 mike 2290:
2291: <p>The output of the tokenization step is a series of zero or more
2292: of the following tokens: DOCTYPE, start tag, end tag, comment,
2293: character, end-of-file. DOCTYPE tokens have a name, a public
2294: identifier, a system identifier, and a <i>force-quirks
2295: flag</i>. When a DOCTYPE token is created, its name, public
2296: identifier, and system identifier must be marked as missing (which
2297: is a distinct state from the empty string), and the <i>force-quirks
2298: flag</i> must be set to <i>off</i> (its other state is
2299: <i>on</i>). Start and end tag tokens have a tag name, a
2300: <i>self-closing flag</i>, and a list of attributes, each of which
2301: has a name and a value. When a start or end tag token is created,
2302: its <i>self-closing flag</i> must be unset (its other state is that
2303: it be set), and its attributes list must be empty. Comment and
2304: character tokens have data.</p>
2305:
2306: <p>When a token is emitted, it must immediately be handled by the
2307: <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541 mike 2308: can affect the state of the tokenization stage, and can insert
2309: additional characters into the stream. (For example, the
1.1 mike 2310: <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159 mike 2311: using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1 mike 2312: characters into the stream being tokenized.)</p>
2313:
2314: <p>When a start tag token is emitted with its <i>self-closing
2315: flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
2316: self-closing flag">acknowledged</dfn> when it is processed by the
2317: tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
2318:
2319: <p>When an end tag token is emitted with attributes, that is a
2320: <a href="#parse-error">parse error</a>.</p>
2321:
2322: <p>When an end tag token is emitted with its <i>self-closing
2323: flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
2324:
1.541 mike 2325: <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
2326: tag name matches the tag name of the last start tag to have been
2327: emitted from this tokenizer, if any. If no start tag has been
2328: emitted from this tokenizer, then no end tag token is
2329: appropriate.</p>
2330:
1.1 mike 2331: <p>Before each step of the tokenizer, the user agent must first
2332: check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
2333: tokenizer must abort the processing of any nested invocations of the
1.479 mike 2334: tokenizer, yielding control back to the caller.</p>
1.1 mike 2335:
2336: <p>The tokenizer state machine consists of the states defined in the
2337: following subsections.</p>
2338:
1.541 mike 2339:
1.333 mike 2340: <!-- Order of the lists below is supposed to be non-error then
2341: error, by unicode, then EOF, ending with "anything else" -->
1.1 mike 2342:
1.541 mike 2343:
1.895 mike 2344: <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 2345:
2346: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2347:
2348: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.541 mike 2349: <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56 mike 2350: state</a>.</dd>
1.1 mike 2351:
1.541 mike 2352: <dt>U+003C LESS-THAN SIGN (<)</dt>
2353: <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
2354:
2355: <dt>EOF</dt>
2356: <dd>Emit an end-of-file token.</dd>
2357:
2358: <dt>Anything else</dt>
2359: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2360: token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2361:
1.895 mike 2362: </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 2363:
2364: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2365: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2366:
2367: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2368: token.</p>
2369:
2370: <p>Otherwise, emit the character token that was returned.</p>
2371:
2372: <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
2373:
2374:
1.895 mike 2375: <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 2376:
1.541 mike 2377: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2378:
1.541 mike 2379: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.618 mike 2380: <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541 mike 2381: state</a>.</dd>
1.1 mike 2382:
2383: <dt>U+003C LESS-THAN SIGN (<)</dt>
1.541 mike 2384: <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
2385:
2386: <dt>EOF</dt>
2387: <dd>Emit an end-of-file token.</dd>
1.1 mike 2388:
1.541 mike 2389: <dt>Anything else</dt>
2390: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2391: token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 2392:
1.755 mike 2393: </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 2394:
2395: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2396: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2397:
2398: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2399: token.</p>
2400:
2401: <p>Otherwise, emit the character token that was returned.</p>
2402:
2403: <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
2404:
2405:
1.895 mike 2406: <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 2407:
1.541 mike 2408: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2409:
1.541 mike 2410: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2411: <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1 mike 2412:
2413: <dt>EOF</dt>
2414: <dd>Emit an end-of-file token.</dd>
2415:
2416: <dt>Anything else</dt>
1.541 mike 2417: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2418: token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 2419:
1.895 mike 2420: </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 2421:
1.541 mike 2422: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2423:
1.541 mike 2424: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2425: <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1 mike 2426:
1.541 mike 2427: <dt>EOF</dt>
2428: <dd>Emit an end-of-file token.</dd>
1.1 mike 2429:
1.541 mike 2430: <dt>Anything else</dt>
2431: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2432: token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2433:
1.895 mike 2434: </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 2435:
1.541 mike 2436: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2437:
1.541 mike 2438: <dl class="switch"><dt>EOF</dt>
2439: <dd>Emit an end-of-file token.</dd>
1.1 mike 2440:
1.541 mike 2441: <dt>Anything else</dt>
2442: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2443: token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1 mike 2444:
1.895 mike 2445: </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 2446:
1.541 mike 2447: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2448:
1.541 mike 2449: <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
2450: <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1 mike 2451:
1.541 mike 2452: <dt>U+002F SOLIDUS (/)</dt>
1.755 mike 2453: <dd>Switch to the <a href="#end-tag-open-state">end tag open state</a>.</dd>
1.1 mike 2454:
1.541 mike 2455: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2456: <dd>Create a new start tag token, set its tag name to the
2457: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
2458: character's code point), then switch to the <a href="#tag-name-state">tag name
2459: state</a>. (Don't emit the token yet; further details will
2460: be filled in before it is emitted.)</dd>
1.1 mike 2461:
1.541 mike 2462: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2463: <dd>Create a new start tag token, set its tag name to the
2464: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2465: name state</a>. (Don't emit the token yet; further details will
2466: be filled in before it is emitted.)</dd>
1.1 mike 2467:
1.541 mike 2468: <dt>U+003F QUESTION MARK (?)</dt>
2469: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2470: comment state</a>.</dd>
1.1 mike 2471:
1.541 mike 2472: <dt>Anything else</dt>
2473: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2474: character token and reconsume the <a href="#current-input-character">current input
2475: character</a> in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2476:
1.755 mike 2477: </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 2478:
1.541 mike 2479: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2480:
2481: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2482: <dd>Create a new end tag token, set its tag name to the lowercase
1.541 mike 2483: version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
2484: the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1 mike 2485: state</a>. (Don't emit the token yet; further details will be
2486: filled in before it is emitted.)</dd>
2487:
2488: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541 mike 2489: <dd>Create a new end tag token, set its tag name to the
2490: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2491: name state</a>. (Don't emit the token yet; further details will
2492: be filled in before it is emitted.)</dd>
1.1 mike 2493:
2494: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2495: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
2496: state</a>.</dd>
2497:
2498: <dt>EOF</dt>
2499: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2500: character token and a U+002F SOLIDUS character token. Reconsume
2501: the EOF character in the <a href="#data-state">data state</a>.</dd>
2502:
2503: <dt>Anything else</dt>
2504: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2505: comment state</a>.</dd>
2506:
1.895 mike 2507: </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 2508:
2509: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2510:
2511: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2512: <dt>U+000A LINE FEED (LF)</dt>
2513: <dt>U+000C FORM FEED (FF)</dt>
2514: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2515: <dt>U+0020 SPACE</dt>
2516: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
2517:
2518: <dt>U+002F SOLIDUS (/)</dt>
2519: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
2520:
2521: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2522: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
2523: state</a>.</dd>
2524:
2525: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 2526: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2527: character</a> (add 0x0020 to the character's code point) to the
2528: current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
2529: state</a>.</dd>
2530:
2531: <dt>EOF</dt>
2532: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2533: <a href="#data-state">data state</a>.</dd>
2534:
2535: <dt>Anything else</dt>
2536: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2537: tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
2538:
1.895 mike 2539: </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 2540: <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
2541:
2542: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2543:
2544: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2545: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2546: to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
2547:
2548: <dt>Anything else</dt>
2549: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2550: <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
2551: state</a>.</dd>
2552:
1.895 mike 2553: </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 2554: <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
2555:
2556: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2557:
2558: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2559: <dd>Create a new end tag token, and set its tag name to the
2560: lowercase version of the <a href="#current-input-character">current input character</a> (add
2561: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2562: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2563: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2564: the token yet; further details will be filled in before it is
2565: emitted.)</dd>
2566:
2567: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2568: <dd>Create a new end tag token, and set its tag name to the
2569: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2570: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2571: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2572: the token yet; further details will be filled in before it is
2573: emitted.)</dd>
2574:
2575: <dt>Anything else</dt>
2576: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2577: character token, and reconsume the <a href="#current-input-character">current input
2578: character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2579:
1.895 mike 2580: </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 2581: <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
2582:
2583: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2584:
2585: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2586: <dt>U+000A LINE FEED (LF)</dt>
2587: <dt>U+000C FORM FEED (FF)</dt>
2588: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2589: <dt>U+0020 SPACE</dt>
2590: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2591: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2592: state</a>. Otherwise, treat it as per the "anything else" entry
2593: below.</dd>
2594:
2595: <dt>U+002F SOLIDUS (/)</dt>
2596: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2597: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2598: state</a>. Otherwise, treat it as per the "anything else" entry
2599: below.</dd>
2600:
2601: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2602: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2603: token</a>, then emit the current tag token and switch to the
2604: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2605: else" entry below.</dd>
2606:
2607: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2608: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2609: character</a> (add 0x0020 to the character's code point) to the
2610: current tag token's tag name. Append the <a href="#current-input-character">current input
2611: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2612: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2613:
2614: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2615: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2616: tag token's tag name. Append the <a href="#current-input-character">current input
2617: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2618: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2619:
2620: <dt>Anything else</dt>
2621: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2622: character token, a character token for each of the characters in
2623: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2624: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2625: in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2626:
1.895 mike 2627: </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 2628: <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
2629:
2630: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2631:
2632: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2633: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2634: to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
2635:
2636: <dt>Anything else</dt>
2637: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2638: <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
2639: state</a>.</dd>
2640:
1.895 mike 2641: </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 2642: <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
2643:
2644: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2645:
2646: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2647: <dd>Create a new end tag token, and set its tag name to the
2648: lowercase version of the <a href="#current-input-character">current input character</a> (add
2649: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2650: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2651: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2652: the token yet; further details will be filled in before it is
2653: emitted.)</dd>
2654:
2655: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2656: <dd>Create a new end tag token, and set its tag name to the
2657: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2658: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2659: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2660: the token yet; further details will be filled in before it is
2661: emitted.)</dd>
2662:
2663: <dt>Anything else</dt>
2664: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2665: character token, and reconsume the <a href="#current-input-character">current input
2666: character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2667:
1.895 mike 2668: </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 2669: <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
2670:
2671: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2672:
2673: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2674: <dt>U+000A LINE FEED (LF)</dt>
2675: <dt>U+000C FORM FEED (FF)</dt>
2676: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2677: <dt>U+0020 SPACE</dt>
2678: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2679: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2680: state</a>. Otherwise, treat it as per the "anything else" entry
2681: below.</dd>
2682:
2683: <dt>U+002F SOLIDUS (/)</dt>
2684: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2685: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2686: state</a>. Otherwise, treat it as per the "anything else" entry
2687: below.</dd>
2688:
2689: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2690: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2691: token</a>, then emit the current tag token and switch to the
2692: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2693: else" entry below.</dd>
2694:
2695: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2696: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2697: character</a> (add 0x0020 to the character's code point) to the
2698: current tag token's tag name. Append the <a href="#current-input-character">current input
2699: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2700: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2701:
2702: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2703: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2704: tag token's tag name. Append the <a href="#current-input-character">current input
2705: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2706: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2707:
2708: <dt>Anything else</dt>
2709: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2710: character token, a character token for each of the characters in
2711: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2712: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2713: in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2714:
1.895 mike 2715: </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 2716:
2717: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2718:
2719: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2720: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2721: to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
2722:
2723: <dt>U+0021 EXCLAMATION MARK (!)</dt>
2724: <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
2725: EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
2726: escape start state</a>.</dd>
2727:
2728: <dt>Anything else</dt>
2729: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2730: <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
2731: state</a>.</dd>
2732:
1.895 mike 2733: </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 2734: <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
2735:
2736: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2737:
2738: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2739: <dd>Create a new end tag token, and set its tag name to the
2740: lowercase version of the <a href="#current-input-character">current input character</a> (add
2741: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2742: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2743: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2744: the token yet; further details will be filled in before it is
2745: emitted.)</dd>
2746:
2747: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2748: <dd>Create a new end tag token, and set its tag name to the
2749: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2750: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2751: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2752: the token yet; further details will be filled in before it is
2753: emitted.)</dd>
2754:
2755: <dt>Anything else</dt>
2756: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2757: character token, and reconsume the <a href="#current-input-character">current input
2758: character</a> in the <a href="#script-data-state">script data state</a>.</dd>
2759:
1.895 mike 2760: </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 2761: <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
2762:
2763: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2764:
2765: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2766: <dt>U+000A LINE FEED (LF)</dt>
2767: <dt>U+000C FORM FEED (FF)</dt>
2768: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2769: <dt>U+0020 SPACE</dt>
2770: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2771: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2772: state</a>. Otherwise, treat it as per the "anything else" entry
2773: below.</dd>
2774:
2775: <dt>U+002F SOLIDUS (/)</dt>
2776: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2777: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2778: state</a>. Otherwise, treat it as per the "anything else" entry
2779: below.</dd>
2780:
2781: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2782: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2783: token</a>, then emit the current tag token and switch to the
2784: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2785: else" entry below.</dd>
2786:
2787: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2788: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2789: character</a> (add 0x0020 to the character's code point) to the
2790: current tag token's tag name. Append the <a href="#current-input-character">current input
2791: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2792: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2793:
2794: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2795: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2796: tag token's tag name. Append the <a href="#current-input-character">current input
2797: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2798: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2799:
2800: <dt>Anything else</dt>
2801: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2802: character token, a character token for each of the characters in
2803: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2804: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2805: in the <a href="#script-data-state">script data state</a>.</dd>
2806:
1.895 mike 2807: </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 2808:
2809: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2810:
2811: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2812: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2813: <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
2814:
2815: <dt>Anything else</dt>
2816: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2817: <a href="#script-data-state">script data state</a>.</dd>
2818:
1.895 mike 2819: </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 2820:
2821: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2822:
2823: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2824: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2825: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2826:
2827: <dt>Anything else</dt>
2828: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2829: <a href="#script-data-state">script data state</a>.</dd>
2830:
1.895 mike 2831: </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 2832:
2833: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2834:
2835: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2836: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2837: <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
2838:
1.542 mike 2839: <dt>U+003C LESS-THAN SIGN (<)</dt>
2840: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2841: state</a>.</p></dd>
2842:
1.541 mike 2843: <dt>EOF</dt>
2844: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2845: <a href="#data-state">data state</a>.</dd>
2846:
2847: <dt>Anything else</dt>
1.542 mike 2848: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2849: token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2850:
1.895 mike 2851: </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 2852:
2853: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2854:
2855: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2856: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2857: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2858:
1.542 mike 2859: <dt>U+003C LESS-THAN SIGN (<)</dt>
2860: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2861: state</a>.</p></dd>
2862:
1.541 mike 2863: <dt>EOF</dt>
2864: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2865: <a href="#data-state">data state</a>.</dd>
2866:
2867: <dt>Anything else</dt>
1.542 mike 2868: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2869: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2870:
1.895 mike 2871: </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 2872:
2873: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2874:
2875: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2876: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
2877: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2878:
1.542 mike 2879: <dt>U+003C LESS-THAN SIGN (<)</dt>
2880: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2881: state</a>.</p></dd>
2882:
1.541 mike 2883: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2884: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
2885: <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2886:
2887: <dt>EOF</dt>
2888: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2889: <a href="#data-state">data state</a>.</dd>
2890:
2891: <dt>Anything else</dt>
1.542 mike 2892: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2893: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2894:
1.895 mike 2895: </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 2896:
2897: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2898:
2899: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2900: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2901: to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
2902:
2903: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2904: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2905: <a href="#current-input-character">current input character</a> as a character token. Set the
2906: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2907: lowercase version of the <a href="#current-input-character">current input character</a> (add
2908: 0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
2909: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2910: state</a>.</dd>
2911:
2912: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2913: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2914: <a href="#current-input-character">current input character</a> as a character token. Set the
2915: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2916: <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
2917: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2918: state</a>.</dd>
2919:
2920: <dt>Anything else</dt>
2921: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2922: <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
2923: escaped state</a>.</dd>
2924:
1.895 mike 2925: </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 2926:
2927: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2928:
2929: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2930: <dd>Create a new end tag token, and set its tag name to the
2931: lowercase version of the <a href="#current-input-character">current input character</a> (add
2932: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2933: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2934: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2935: state</a>. (Don't emit the token yet; further details will be
2936: filled in before it is emitted.)</dd>
2937:
2938: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2939: <dd>Create a new end tag token, and set its tag name to the
2940: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2941: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2942: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2943: state</a>. (Don't emit the token yet; further details will be
2944: filled in before it is emitted.)</dd>
2945:
2946: <dt>Anything else</dt>
2947: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2948: character token, and reconsume the <a href="#current-input-character">current input
2949: character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2950:
1.895 mike 2951: </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 2952:
2953: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2954:
2955: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2956: <dt>U+000A LINE FEED (LF)</dt>
2957: <dt>U+000C FORM FEED (FF)</dt>
2958: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2959: <dt>U+0020 SPACE</dt>
2960: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2961: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2962: state</a>. Otherwise, treat it as per the "anything else" entry
2963: below.</dd>
2964:
2965: <dt>U+002F SOLIDUS (/)</dt>
2966: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2967: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2968: state</a>. Otherwise, treat it as per the "anything else" entry
2969: below.</dd>
2970:
2971: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2972: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2973: token</a>, then emit the current tag token and switch to the
2974: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2975: else" entry below.</dd>
2976:
2977: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2978: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2979: character</a> (add 0x0020 to the character's code point) to the
2980: current tag token's tag name. Append the <a href="#current-input-character">current input
2981: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2982: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2983:
2984: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2985: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2986: tag token's tag name. Append the <a href="#current-input-character">current input
2987: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2988: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2989:
2990: <dt>Anything else</dt>
2991: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2992: character token, a character token for each of the characters in
2993: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2994: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2995: in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2996:
1.895 mike 2997: </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 2998:
2999: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3000:
3001: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3002: <dt>U+000A LINE FEED (LF)</dt>
3003: <dt>U+000C FORM FEED (FF)</dt>
3004: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3005: <dt>U+0020 SPACE</dt>
3006: <dt>U+002F SOLIDUS (/)</dt>
3007: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3008: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3009: 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
3010: double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
3011: data escaped state</a>.</dd>
3012:
3013: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3014: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3015: token. Append the lowercase version of the <a href="#current-input-character">current input
3016: character</a> (add 0x0020 to the character's code point) to the
3017: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
3018: escape start state</a>.</dd>
3019:
3020: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
3021: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3022: token. Append the <a href="#current-input-character">current input character</a> to the
3023: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
3024: escape start state</a>.</dd>
3025:
3026: <dt>Anything else</dt>
3027: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3028: <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
3029:
1.895 mike 3030: </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 3031:
3032: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3033:
3034: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3035: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
3036: <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
3037:
3038: <dt>U+003C LESS-THAN SIGN (<)</dt>
3039: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
3040: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
3041: state</a>.</p></dd>
3042:
3043: <dt>EOF</dt>
3044: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3045: <a href="#data-state">data state</a>.</dd>
3046:
3047: <dt>Anything else</dt>
3048: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3049: token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
3050: state</a>.</dd>
3051:
1.895 mike 3052: </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 3053:
3054: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3055:
3056: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3057: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
3058: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
3059:
3060: <dt>U+003C LESS-THAN SIGN (<)</dt>
3061: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
3062: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
3063: state</a>.</p></dd>
3064:
3065: <dt>EOF</dt>
3066: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3067: <a href="#data-state">data state</a>.</dd>
3068:
3069: <dt>Anything else</dt>
3070: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3071: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
3072: state</a>.</dd>
3073:
1.895 mike 3074: </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 3075:
3076: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3077:
3078: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3079: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
3080: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
3081:
3082: <dt>U+003C LESS-THAN SIGN (<)</dt>
3083: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
3084: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
3085: state</a>.</p></dd>
3086:
3087: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3088: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
3089: <a href="#script-data-state">script data state</a>.</dd>
3090:
3091: <dt>EOF</dt>
3092: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3093: <a href="#data-state">data state</a>.</dd>
3094:
3095: <dt>Anything else</dt>
3096: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3097: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
3098: state</a>.</dd>
3099:
1.895 mike 3100: </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 3101:
3102: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3103:
3104: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
3105: <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
3106: buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
3107: double escape end state</a>.</dd>
3108:
3109: <dt>Anything else</dt>
3110: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3111: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
3112:
1.895 mike 3113: </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 3114:
3115: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3116:
3117: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3118: <dt>U+000A LINE FEED (LF)</dt>
3119: <dt>U+000C FORM FEED (FF)</dt>
3120: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3121: <dt>U+0020 SPACE</dt>
3122: <dt>U+002F SOLIDUS (/)</dt>
3123: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3124: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3125: 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
3126: escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
3127: double escaped state</a>.</dd>
3128:
3129: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3130: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3131: token. Append the lowercase version of the <a href="#current-input-character">current input
3132: character</a> (add 0x0020 to the character's code point) to the
3133: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
3134: escape end state</a>.</dd>
3135:
3136: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
3137: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3138: token. Append the <a href="#current-input-character">current input character</a> to the
3139: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
3140: escape end state</a>.</dd>
3141:
3142: <dt>Anything else</dt>
3143: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3144: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1 mike 3145:
1.895 mike 3146: </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 3147:
3148: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3149:
3150: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3151: <dt>U+000A LINE FEED (LF)</dt>
3152: <dt>U+000C FORM FEED (FF)</dt>
3153: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3154: <dt>U+0020 SPACE</dt>
3155: <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3156:
3157: <dt>U+002F SOLIDUS (/)</dt>
3158: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3159:
3160: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3161: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3162: state</a>.</dd>
3163:
3164: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3165: <dd>Start a new attribute in the current tag token. Set that
3166: attribute's name to the lowercase version of the <a href="#current-input-character">current input
3167: character</a> (add 0x0020 to the character's code point), and its
3168: value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
3169: state</a>.</dd>
3170:
3171: <dt>U+0022 QUOTATION MARK (")</dt>
3172: <dt>U+0027 APOSTROPHE (')</dt>
3173: <dt>U+003C LESS-THAN SIGN (<)</dt>
3174: <dt>U+003D EQUALS SIGN (=)</dt>
3175: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3176: entry below.</dd>
3177:
3178: <dt>EOF</dt>
3179: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3180: <a href="#data-state">data state</a>.</dd>
3181:
3182: <dt>Anything else</dt>
3183: <dd>Start a new attribute in the current tag token. Set that
3184: attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
3185: the empty string. Switch to the <a href="#attribute-name-state">attribute name
3186: state</a>.</dd>
3187:
1.895 mike 3188: </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 3189:
3190: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3191:
3192: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3193: <dt>U+000A LINE FEED (LF)</dt>
3194: <dt>U+000C FORM FEED (FF)</dt>
3195: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3196: <dt>U+0020 SPACE</dt>
3197: <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3198:
3199: <dt>U+002F SOLIDUS (/)</dt>
3200: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3201:
3202: <dt>U+003D EQUALS SIGN (=)</dt>
3203: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3204:
3205: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3206: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3207: state</a>.</dd>
3208:
3209: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3210: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3211: character</a> (add 0x0020 to the character's code point) to the
3212: current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1 mike 3213: state</a>.</dd>
3214:
3215: <dt>U+0022 QUOTATION MARK (")</dt>
3216: <dt>U+0027 APOSTROPHE (')</dt>
3217: <dt>U+003C LESS-THAN SIGN (<)</dt>
3218: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3219: entry below.</dd>
3220:
3221: <dt>EOF</dt>
3222: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3223: <a href="#data-state">data state</a>.</dd>
3224:
3225: <dt>Anything else</dt>
1.541 mike 3226: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3227: attribute's name. Stay in the <a href="#attribute-name-state">attribute name
3228: state</a>.</dd>
1.1 mike 3229:
3230: </dl><p>When the user agent leaves the attribute name state (and before
3231: emitting the tag token, if appropriate), the complete attribute's
3232: name must be compared to the other attributes on the same token;
3233: if there is already an attribute on the token with the exact same
3234: name, then this is a <a href="#parse-error">parse error</a> and the new
3235: attribute must be dropped, along with the value that gets
3236: associated with it (if any).</p>
3237:
3238:
1.895 mike 3239: <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 3240:
3241: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3242:
3243: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3244: <dt>U+000A LINE FEED (LF)</dt>
3245: <dt>U+000C FORM FEED (FF)</dt>
3246: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3247: <dt>U+0020 SPACE</dt>
3248: <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3249:
3250: <dt>U+002F SOLIDUS (/)</dt>
3251: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3252:
3253: <dt>U+003D EQUALS SIGN (=)</dt>
3254: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3255:
3256: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3257: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3258: state</a>.</dd>
3259:
3260: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3261: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3262: attribute's name to the lowercase version of the <a href="#current-input-character">current
3263: input character</a> (add 0x0020 to the character's code point),
3264: and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
3265: name state</a>.</dd>
1.1 mike 3266:
3267: <dt>U+0022 QUOTATION MARK (")</dt>
3268: <dt>U+0027 APOSTROPHE (')</dt>
3269: <dt>U+003C LESS-THAN SIGN (<)</dt>
3270: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3271: entry below.</dd>
3272:
3273: <dt>EOF</dt>
3274: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3275: <a href="#data-state">data state</a>.</dd>
3276:
3277: <dt>Anything else</dt>
3278: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3279: attribute's name to the <a href="#current-input-character">current input character</a>, and
3280: its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1 mike 3281: state</a>.</dd>
3282:
1.895 mike 3283: </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 3284:
3285: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3286:
3287: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3288: <dt>U+000A LINE FEED (LF)</dt>
3289: <dt>U+000C FORM FEED (FF)</dt>
3290: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3291: <dt>U+0020 SPACE</dt>
3292: <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3293:
3294: <dt>U+0022 QUOTATION MARK (")</dt>
3295: <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
3296:
3297: <dt>U+0026 AMPERSAND (&)</dt>
3298: <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541 mike 3299: and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1 mike 3300:
3301: <dt>U+0027 APOSTROPHE (')</dt>
3302: <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
3303:
3304: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3305: <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
3306: the <a href="#data-state">data state</a>.</dd>
3307:
3308: <dt>U+003C LESS-THAN SIGN (<)</dt>
3309: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3310: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3311: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3312: entry below.</dd>
3313:
3314: <dt>EOF</dt>
3315: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3316: <a href="#data-state">data state</a>.</dd>
3317:
3318: <dt>Anything else</dt>
3319: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3320: attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
3321: state</a>.</dd>
3322:
1.755 mike 3323: </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 3324:
3325: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3326:
3327: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3328: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3329: state</a>.</dd>
3330:
3331: <dt>U+0026 AMPERSAND (&)</dt>
3332: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3333: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3334: being U+0022 QUOTATION MARK (").</dd>
3335:
3336: <dt>EOF</dt>
3337: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3338: <a href="#data-state">data state</a>.</dd>
3339:
3340: <dt>Anything else</dt>
1.541 mike 3341: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3342: attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
3343: (double-quoted) state</a>.</dd>
1.1 mike 3344:
1.755 mike 3345: </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 3346:
3347: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3348:
3349: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3350: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3351: state</a>.</dd>
3352:
3353: <dt>U+0026 AMPERSAND (&)</dt>
3354: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3355: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3356: being U+0027 APOSTROPHE (').</dd>
3357:
3358: <dt>EOF</dt>
3359: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3360: <a href="#data-state">data state</a>.</dd>
3361:
3362: <dt>Anything else</dt>
1.541 mike 3363: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3364: attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
3365: (single-quoted) state</a>.</dd>
1.1 mike 3366:
1.755 mike 3367: </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 3368:
3369: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3370:
3371: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3372: <dt>U+000A LINE FEED (LF)</dt>
3373: <dt>U+000C FORM FEED (FF)</dt>
3374: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3375: <dt>U+0020 SPACE</dt>
3376: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3377:
3378: <dt>U+0026 AMPERSAND (&)</dt>
3379: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299 mike 3380: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3381: being U+003E GREATER-THAN SIGN (>).</dd>
1.1 mike 3382:
3383: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3384: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3385: state</a>.</dd>
3386:
3387: <dt>U+0022 QUOTATION MARK (")</dt>
3388: <dt>U+0027 APOSTROPHE (')</dt>
3389: <dt>U+003C LESS-THAN SIGN (<)</dt>
3390: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3391: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3392: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3393: entry below.</dd>
3394:
3395: <dt>EOF</dt>
3396: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3397: <a href="#data-state">data state</a>.</dd>
3398:
3399: <dt>Anything else</dt>
1.541 mike 3400: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3401: attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1 mike 3402: state</a>.</dd>
3403:
1.895 mike 3404: </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 3405:
3406: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
3407:
3408: <p>If nothing is returned, append a U+0026 AMPERSAND character to
3409: the current attribute's value.</p>
3410:
3411: <p>Otherwise, append the returned character token to the current
3412: attribute's value.</p>
3413:
3414: <p>Finally, switch back to the attribute value state that you were
3415: in when were switched into this state.</p>
3416:
3417:
1.755 mike 3418: <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 3419:
3420: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3421:
3422: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3423: <dt>U+000A LINE FEED (LF)</dt>
3424: <dt>U+000C FORM FEED (FF)</dt>
3425: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3426: <dt>U+0020 SPACE</dt>
3427: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3428:
3429: <dt>U+002F SOLIDUS (/)</dt>
3430: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3431:
3432: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3433: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3434: state</a>.</dd>
3435:
3436: <dt>EOF</dt>
3437: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3438: <a href="#data-state">data state</a>.</dd>
3439:
3440: <dt>Anything else</dt>
3441: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3442: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3443:
1.895 mike 3444: </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 3445:
3446: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3447:
3448: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3449: <dd>Set the <i>self-closing flag</i> of the current tag
3450: token. Emit the current tag token. Switch to the <a href="#data-state">data
3451: state</a>.</dd>
3452:
3453: <dt>EOF</dt>
3454: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3455: <a href="#data-state">data state</a>.</dd>
3456:
3457: <dt>Anything else</dt>
3458: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3459: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3460:
1.895 mike 3461: </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 3462:
3463: <p>Consume every character up to and including the first U+003E
3464: GREATER-THAN SIGN character (>) or the end of the file (EOF),
3465: whichever comes first. Emit a comment token whose data is the
3466: concatenation of all the characters starting from and including
3467: the character that caused the state machine to switch into the
3468: bogus comment state, up to and including the character immediately
3469: before the last consumed character (i.e. up to the character just
3470: before the U+003E or EOF character). (If the comment was started
3471: by the end of the file (EOF), the token is empty.)</p>
3472:
3473: <p>Switch to the <a href="#data-state">data state</a>.</p>
3474:
3475: <p>If the end of the file was reached, reconsume the EOF
3476: character.</p>
3477:
3478:
1.895 mike 3479: <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 3480:
1.588 mike 3481: <p>If the next two characters are both U+002D HYPHEN-MINUS
3482: characters (-), consume those two characters, create a comment token
1.1 mike 3483: whose data is the empty string, and switch to the <a href="#comment-start-state">comment
3484: start state</a>.</p>
3485:
3486: <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3487: case-insensitive</a> match for the word "DOCTYPE", then consume
3488: those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
3489:
3490: <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
3491: content</a>" and the <a href="#current-node">current node</a> is not an element
1.724 mike 3492: in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585 mike 3493: an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
3494: five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
3495: character before and after), then consume those characters and
3496: switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1 mike 3497:
3498: <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
3499: <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
3500: consumed, if any, is the first character that will be in the
3501: comment.</p>
3502:
3503:
1.895 mike 3504: <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 3505:
3506: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3507:
3508: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3509: <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
3510:
3511: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3512: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
3513: <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
3514: -->
3515:
3516: <dt>EOF</dt>
3517: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3518: the EOF character in the <a href="#data-state">data state</a>.</dd>
3519:
3520: <dt>Anything else</dt>
1.541 mike 3521: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3522: token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3523:
1.895 mike 3524: </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 3525:
3526: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3527:
3528: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3529: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3530:
3531: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3532: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
3533: the <a href="#data-state">data state</a>.</dd>
3534:
3535: <dt>EOF</dt>
3536: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3537: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3538: in comment end state -->
3539:
3540: <dt>Anything else</dt>
1.541 mike 3541: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3542: <a href="#current-input-character">current input character</a> to the comment token's
3543: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3544:
1.895 mike 3545: </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 3546:
3547: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3548:
3549: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3550: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
3551:
3552: <dt>EOF</dt>
3553: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3554: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3555: in comment end state -->
3556:
3557: <dt>Anything else</dt>
1.541 mike 3558: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3559: token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3560:
1.895 mike 3561: </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 3562:
3563: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3564:
3565: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3566: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3567:
3568: <dt>EOF</dt>
3569: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3570: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3571: in comment end state -->
3572:
3573: <dt>Anything else</dt>
1.541 mike 3574: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3575: <a href="#current-input-character">current input character</a> to the comment token's
3576: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3577:
1.895 mike 3578: </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 3579:
3580: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3581:
3582: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3583: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3584: state</a>.</dd>
3585:
3586: <dt>U+0009 CHARACTER TABULATION</dt>
3587: <dt>U+000A LINE FEED (LF)</dt>
3588: <dt>U+000C FORM FEED (FF)</dt>
3589: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3590: <dt>U+0020 SPACE</dt>
1.588 mike 3591: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3592: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3593: comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
3594: state</a>.</dd>
1.1 mike 3595:
3596: <dt>U+0021 EXCLAMATION MARK (!)</dt>
3597: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
3598: state</a>.</dd>
3599:
1.333 mike 3600: <dt>U+002D HYPHEN-MINUS (-)</dt>
3601: <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464 mike 3602: character (-) to the comment token's data. Stay in the
1.333 mike 3603: <a href="#comment-end-state">comment end state</a>.</dd>
3604:
1.1 mike 3605: <dt>EOF</dt>
3606: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3607: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
1.724 mike 3608: security reasons: otherwise, hostile user could put a <script type="text/javascript"> in
1.1 mike 3609: a comment e.g. in a blog comment and then DOS the server so that
1.724 mike 3610: the end tag isn't read, and then the commented <script type="text/javascript"> tag would
1.1 mike 3611: be treated as live code -->
3612:
3613: <dt>Anything else</dt>
1.588 mike 3614: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3615: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3616: comment token's data. Switch to the <a href="#comment-state">comment
3617: state</a>.</dd>
1.1 mike 3618:
1.895 mike 3619: </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 3620:
3621: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3622:
1.333 mike 3623: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588 mike 3624: <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464 mike 3625: EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1 mike 3626: to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3627:
1.333 mike 3628: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3629: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3630: state</a>.</dd>
3631:
1.1 mike 3632: <dt>EOF</dt>
3633: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3634: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3635: comment in comment end state -->
3636:
3637: <dt>Anything else</dt>
1.588 mike 3638: <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541 mike 3639: EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
3640: character</a> to the comment token's data. Switch to the
3641: <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3642:
1.895 mike 3643: </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 3644:
3645: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3646:
1.333 mike 3647: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1 mike 3648: <dt>U+000A LINE FEED (LF)</dt>
3649: <dt>U+000C FORM FEED (FF)</dt>
3650: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3651: <dt>U+0020 SPACE</dt>
1.541 mike 3652: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1 mike 3653: the <a href="#comment-end-space-state">comment end space state</a>.</dd>
3654:
1.333 mike 3655: <dt>U+002D HYPHEN-MINUS (-)</dt>
3656: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3657:
3658: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3659: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3660: state</a>.</dd>
3661:
1.1 mike 3662: <dt>EOF</dt>
3663: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3664: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3665: comment in comment end state -->
3666:
3667: <dt>Anything else</dt>
1.541 mike 3668: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1 mike 3669: to the <a href="#comment-state">comment state</a>.</dd>
3670:
1.895 mike 3671: </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 3672:
3673: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3674:
3675: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3676: <dt>U+000A LINE FEED (LF)</dt>
3677: <dt>U+000C FORM FEED (FF)</dt>
3678: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3679: <dt>U+0020 SPACE</dt>
3680: <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3681:
3682: <dt>EOF</dt>
3683: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3684: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3685: the EOF character in the <a href="#data-state">data state</a>.</dd>
3686:
3687: <dt>Anything else</dt>
1.608 mike 3688: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
3689: <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1 mike 3690:
1.895 mike 3691: </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 3692:
3693: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3694:
3695: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3696: <dt>U+000A LINE FEED (LF)</dt>
3697: <dt>U+000C FORM FEED (FF)</dt>
3698: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3699: <dt>U+0020 SPACE</dt>
3700: <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3701:
3702: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3703: <dd>Create a new DOCTYPE token. Set the token's name to the
1.541 mike 3704: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1 mike 3705: character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
3706: state</a>.</dd>
3707:
1.333 mike 3708: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3709: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3710: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
3711: the <a href="#data-state">data state</a>.</dd>
3712:
1.1 mike 3713: <dt>EOF</dt>
3714: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3715: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3716: the EOF character in the <a href="#data-state">data state</a>.</dd>
3717:
3718: <dt>Anything else</dt>
3719: <dd>Create a new DOCTYPE token. Set the token's name to the
3720: <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
3721: state</a>.</dd>
3722:
1.895 mike 3723: </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 3724:
3725: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3726:
3727: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3728: <dt>U+000A LINE FEED (LF)</dt>
3729: <dt>U+000C FORM FEED (FF)</dt>
3730: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3731: <dt>U+0020 SPACE</dt>
3732: <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3733:
3734: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3735: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3736: state</a>.</dd>
3737:
3738: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3739: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3740: character</a> (add 0x0020 to the character's code point) to the
3741: current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3742: state</a>.</dd>
1.1 mike 3743:
3744: <dt>EOF</dt>
3745: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3746: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3747: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3748:
3749: <dt>Anything else</dt>
1.541 mike 3750: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3751: DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3752: state</a>.</dd>
1.1 mike 3753:
1.895 mike 3754: </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 3755:
3756: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3757:
3758: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3759: <dt>U+000A LINE FEED (LF)</dt>
3760: <dt>U+000C FORM FEED (FF)</dt>
3761: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3762: <dt>U+0020 SPACE</dt>
3763: <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3764:
3765: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3766: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3767: state</a>.</dd>
3768:
3769: <dt>EOF</dt>
3770: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3771: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3772: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3773:
3774: <dt>Anything else</dt>
3775: <dd>
3776:
3777: <p>If the six characters starting from the <a href="#current-input-character">current input
3778: character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
3779: for the word "PUBLIC", then consume those characters and switch to
1.444 mike 3780: the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1 mike 3781:
3782: <p>Otherwise, if the six characters starting from the
3783: <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3784: case-insensitive</a> match for the word "SYSTEM", then consume
1.444 mike 3785: those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
3786: keyword state</a>.</p>
1.1 mike 3787:
3788: <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
3789: DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
3790: the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
3791:
3792: </dd>
3793:
1.895 mike 3794: </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 3795:
3796: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3797:
3798: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3799: <dt>U+000A LINE FEED (LF)</dt>
3800: <dt>U+000C FORM FEED (FF)</dt>
3801: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3802: <dt>U+0020 SPACE</dt>
3803: <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
3804: state</a>.</dd>
3805:
1.620 mike 3806: <dt>U+0022 QUOTATION MARK (")</dt>
3807: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3808: identifier to the empty string (not missing), then switch to the
3809: <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
3810:
3811: <dt>U+0027 APOSTROPHE (')</dt>
3812: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3813: identifier to the empty string (not missing), then switch to the
3814: <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
3815:
3816: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3817: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3818: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3819: token. Switch to the <a href="#data-state">data state</a>.</dd>
3820:
1.444 mike 3821: <dt>EOF</dt>
3822: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3823: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3824: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3825:
3826: <dt>Anything else</dt>
1.620 mike 3827: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3828: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3829: DOCTYPE state</a>.</dd>
1.444 mike 3830:
1.895 mike 3831: </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 3832:
3833: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3834:
3835: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3836: <dt>U+000A LINE FEED (LF)</dt>
3837: <dt>U+000C FORM FEED (FF)</dt>
3838: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3839: <dt>U+0020 SPACE</dt>
3840: <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
3841:
3842: <dt>U+0022 QUOTATION MARK (")</dt>
3843: <dd>Set the DOCTYPE token's public identifier to the empty string
3844: (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
3845: (double-quoted) state</a>.</dd>
3846:
3847: <dt>U+0027 APOSTROPHE (')</dt>
3848: <dd>Set the DOCTYPE token's public identifier to the empty string
3849: (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
3850: (single-quoted) state</a>.</dd>
3851:
3852: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3853: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3854: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3855: token. Switch to the <a href="#data-state">data state</a>.</dd>
3856:
3857: <dt>EOF</dt>
3858: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3859: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3860: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3861:
3862: <dt>Anything else</dt>
3863: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3864: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3865: DOCTYPE state</a>.</dd>
3866:
1.755 mike 3867: </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 3868:
3869: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3870:
3871: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3872: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3873:
3874: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3875: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3876: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3877: token. Switch to the <a href="#data-state">data state</a>.</dd>
3878:
3879: <dt>EOF</dt>
3880: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3881: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3882: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3883:
3884: <dt>Anything else</dt>
3885: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3886: token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
3887: identifier (double-quoted) state</a>.</dd>
3888:
1.755 mike 3889: </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 3890:
3891: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3892:
3893: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3894: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3895:
3896: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3897: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3898: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3899: token. Switch to the <a href="#data-state">data state</a>.</dd>
3900:
3901: <dt>EOF</dt>
3902: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3903: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3904: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3905:
3906: <dt>Anything else</dt>
3907: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3908: token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
3909: identifier (single-quoted) state</a>.</dd>
3910:
1.895 mike 3911: </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 3912:
3913: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3914:
3915: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3916: <dt>U+000A LINE FEED (LF)</dt>
3917: <dt>U+000C FORM FEED (FF)</dt>
3918: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3919: <dt>U+0020 SPACE</dt>
1.541 mike 3920: <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
3921: identifiers state</a>.</dd>
1.444 mike 3922:
3923: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3924: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3925: state</a>.</dd>
3926:
3927: <dt>U+0022 QUOTATION MARK (")</dt>
3928: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3929: identifier to the empty string (not missing), then switch to the
3930: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3931:
3932: <dt>U+0027 APOSTROPHE (')</dt>
3933: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3934: identifier to the empty string (not missing), then switch to the
3935: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3936:
3937: <dt>EOF</dt>
3938: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3939: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3940: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3941:
3942: <dt>Anything else</dt>
3943: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3944: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3945: DOCTYPE state</a>.</dd>
3946:
1.895 mike 3947: </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 3948:
3949: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3950:
3951: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3952: <dt>U+000A LINE FEED (LF)</dt>
3953: <dt>U+000C FORM FEED (FF)</dt>
3954: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3955: <dt>U+0020 SPACE</dt>
1.541 mike 3956: <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
3957: state</a>.</dd>
1.444 mike 3958:
3959: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3960: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3961: state</a>.</dd>
1.1 mike 3962:
3963: <dt>U+0022 QUOTATION MARK (")</dt>
3964: <dd>Set the DOCTYPE token's system identifier to the empty string
3965: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3966: (double-quoted) state</a>.</dd>
3967:
3968: <dt>U+0027 APOSTROPHE (')</dt>
3969: <dd>Set the DOCTYPE token's system identifier to the empty string
3970: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3971: (single-quoted) state</a>.</dd>
3972:
3973: <dt>EOF</dt>
3974: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3975: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3976: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3977:
3978: <dt>Anything else</dt>
3979: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3980: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3981: DOCTYPE state</a>.</dd>
3982:
1.895 mike 3983: </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 3984:
3985: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3986:
3987: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3988: <dt>U+000A LINE FEED (LF)</dt>
3989: <dt>U+000C FORM FEED (FF)</dt>
3990: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3991: <dt>U+0020 SPACE</dt>
3992: <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
3993: state</a>.</dd>
3994:
1.620 mike 3995: <dt>U+0022 QUOTATION MARK (")</dt>
3996: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3997: identifier to the empty string (not missing), then switch to the
3998: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3999:
4000: <dt>U+0027 APOSTROPHE (')</dt>
4001: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
4002: identifier to the empty string (not missing), then switch to the
4003: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
4004:
4005: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4006: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4007: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4008: token. Switch to the <a href="#data-state">data state</a>.</dd>
4009:
1.444 mike 4010: <dt>EOF</dt>
4011: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4012: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4013: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4014:
4015: <dt>Anything else</dt>
1.620 mike 4016: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4017: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
4018: DOCTYPE state</a>.</dd>
1.444 mike 4019:
1.895 mike 4020: </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 4021:
4022: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4023:
4024: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4025: <dt>U+000A LINE FEED (LF)</dt>
4026: <dt>U+000C FORM FEED (FF)</dt>
4027: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4028: <dt>U+0020 SPACE</dt>
4029: <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
4030:
4031: <dt>U+0022 QUOTATION MARK (")</dt>
4032: <dd>Set the DOCTYPE token's system identifier to the empty string
4033: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
4034: (double-quoted) state</a>.</dd>
4035:
4036: <dt>U+0027 APOSTROPHE (')</dt>
4037: <dd>Set the DOCTYPE token's system identifier to the empty string
4038: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
4039: (single-quoted) state</a>.</dd>
4040:
4041: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4042: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4043: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4044: token. Switch to the <a href="#data-state">data state</a>.</dd>
4045:
4046: <dt>EOF</dt>
4047: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4048: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4049: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4050:
4051: <dt>Anything else</dt>
4052: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4053: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
4054: DOCTYPE state</a>.</dd>
4055:
1.755 mike 4056: </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 4057:
4058: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4059:
4060: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541 mike 4061: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4062: state</a>.</dd>
1.1 mike 4063:
4064: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4065: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4066: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4067: token. Switch to the <a href="#data-state">data state</a>.</dd>
4068:
4069: <dt>EOF</dt>
4070: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4071: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4072: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4073:
4074: <dt>Anything else</dt>
1.541 mike 4075: <dd>Append the <a href="#current-input-character">current input character</a> to the current
4076: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1 mike 4077: identifier (double-quoted) state</a>.</dd>
4078:
1.755 mike 4079: </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 4080:
4081: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4082:
4083: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541 mike 4084: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4085: state</a>.</dd>
1.1 mike 4086:
4087: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4088: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4089: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4090: token. Switch to the <a href="#data-state">data state</a>.</dd>
4091:
4092: <dt>EOF</dt>
4093: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4094: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4095: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4096:
4097: <dt>Anything else</dt>
1.541 mike 4098: <dd>Append the <a href="#current-input-character">current input character</a> to the current
4099: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1 mike 4100: identifier (single-quoted) state</a>.</dd>
4101:
1.895 mike 4102: </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 4103:
4104: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4105:
4106: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4107: <dt>U+000A LINE FEED (LF)</dt>
4108: <dt>U+000C FORM FEED (FF)</dt>
4109: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4110: <dt>U+0020 SPACE</dt>
1.541 mike 4111: <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4112: state</a>.</dd>
1.1 mike 4113:
4114: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4115: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
4116: state</a>.</dd>
4117:
4118: <dt>EOF</dt>
4119: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4120: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4121: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4122:
4123: <dt>Anything else</dt>
4124: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
4125: state</a>. (This does <em>not</em> set the DOCTYPE token's
4126: <i>force-quirks flag</i> to <i>on</i>.)</dd>
4127:
1.895 mike 4128: </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 4129:
4130: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4131:
4132: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
4133: <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
4134: state</a>.</dd>
4135:
4136: <dt>EOF</dt>
4137: <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
4138: <a href="#data-state">data state</a>.</dd>
4139:
4140: <dt>Anything else</dt>
4141: <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
4142:
1.895 mike 4143: </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 4144:
4145: <p>Consume every character up to the next occurrence of the three
4146: character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
4147: BRACKET U+003E GREATER-THAN SIGN (<code title="">]]></code>), or the
4148: end of the file (EOF), whichever comes first. Emit a series of
4149: character tokens consisting of all the characters consumed except
4150: the matching three character sequence at the end (if one was found
4151: before the end of the file).</p>
4152:
4153: <p>Switch to the <a href="#data-state">data state</a>.</p>
4154:
4155: <p>If the end of the file was reached, reconsume the EOF
4156: character.</p>
4157:
4158:
4159:
1.895 mike 4160: <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 4161:
4162: <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
4163: reference</dfn>. This definition is used when parsing character
1.299 mike 4164: references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1 mike 4165: text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
4166: state">in attributes</a>.</p>
4167:
4168: <p>The behavior depends on the identity of the next character (the
4169: one immediately after the U+0026 AMPERSAND character):</p>
4170:
4171: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4172: <dt>U+000A LINE FEED (LF)</dt>
4173: <dt>U+000C FORM FEED (FF)</dt>
4174: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4175: <dt>U+0020 SPACE</dt>
4176: <dt>U+003C LESS-THAN SIGN</dt>
4177: <dt>U+0026 AMPERSAND</dt>
4178: <dt>EOF</dt>
4179: <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
4180:
4181: <dd>Not a character reference. No characters are consumed, and
4182: nothing is returned. (This is not an error, either.)</dd>
4183:
4184:
4185: <dt>U+0023 NUMBER SIGN (#)</dt>
4186:
4187: <dd>
4188:
4189: <p>Consume the U+0023 NUMBER SIGN.</p>
4190:
4191: <p>The behavior further depends on the character after the U+0023
4192: NUMBER SIGN:</p>
4193:
4194: <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
4195: <dt>U+0058 LATIN CAPITAL LETTER X</dt>
4196:
4197: <dd>
4198:
4199: <p>Consume the X.</p>
4200:
4201: <p>Follow the steps below, but using the range of characters
1.464 mike 4202: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
4203: SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
4204: CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
4205: words, 0-9, A-F, a-f).</p>
1.1 mike 4206:
4207: <p>When it comes to interpreting the number, interpret it as a
4208: hexadecimal number.</p>
4209:
4210: </dd>
4211:
4212:
4213: <dt>Anything else</dt>
4214:
4215: <dd>
4216:
4217: <p>Follow the steps below, but using the range of characters
1.464 mike 4218: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1 mike 4219:
4220: <p>When it comes to interpreting the number, interpret it as a
4221: decimal number.</p>
4222:
4223: </dd>
4224:
4225: </dl><p>Consume as many characters as match the range of characters
4226: given above.</p>
4227:
4228: <p>If no characters match the range, then don't consume any
4229: characters (and unconsume the U+0023 NUMBER SIGN character and, if
4230: appropriate, the X character). This is a <a href="#parse-error">parse
4231: error</a>; nothing is returned.</p>
4232:
4233: <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
4234: that too. If it isn't, there is a <a href="#parse-error">parse
4235: error</a>.</p>
4236:
4237: <p>If one or more characters match the range, then take them all
4238: and interpret the string of characters as a number (either
4239: hexadecimal or decimal as appropriate).</p>
4240:
4241: <p>If that number is one of the numbers in the first column of the
4242: following table, then this is a <a href="#parse-error">parse error</a>. Find the
4243: row with that number in the first column, and return a character
4244: token for the Unicode character given in the second column of that
4245: row.</p>
4246:
4247: <table><thead><tr><th>Number </th><th colspan="2">Unicode character
4248: </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
1.882 mike 4249: </td></tr><tr><td>0x0D </td><td>U+000D </td><td>CARRIAGE RETURN (CR)
1.464 mike 4250: </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (€)
1.1 mike 4251: </td></tr><tr><td>0x81 </td><td>U+0081 </td><td><control>
1.464 mike 4252: </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (‚)
4253: </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (ƒ)
4254: </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK („)
4255: </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (…)
4256: </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (†)
4257: </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (‡)
4258: </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
4259: </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (‰)
4260: </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (Š)
4261: </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
4262: </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (Œ)
1.1 mike 4263: </td></tr><tr><td>0x8D </td><td>U+008D </td><td><control>
1.464 mike 4264: </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
1.1 mike 4265: </td></tr><tr><td>0x8F </td><td>U+008F </td><td><control>
4266: </td></tr><tr><td>0x90 </td><td>U+0090 </td><td><control>
1.464 mike 4267: </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (‘)
4268: </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (’)
4269: </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (“)
4270: </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (”)
4271: </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (•)
4272: </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (–)
4273: </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (—)
4274: </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (˜)
4275: </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (™)
4276: </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (š)
4277: </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
4278: </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (œ)
1.1 mike 4279: </td></tr><tr><td>0x9D </td><td>U+009D </td><td><control>
1.464 mike 4280: </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (ž)
4281: </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
1.315 mike 4282: </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
4283: surrogates not allowed; see the comment in the "preprocessing the
4284: input stream" section for details --> or is greater than 0x10FFFF,
4285: then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
4286: REPLACEMENT CHARACTER.</p>
1.18 mike 4287:
4288: <p>Otherwise, return a character token for the Unicode character
1.1 mike 4289: whose code point is that number.
4290:
4291: <!-- this is the same as the equivalent list in the input stream
4292: section -->
4293: If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
4294: allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
4295: allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315 mike 4296: 0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
4297: 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
4298: 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
4299: 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
4300: 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
4301: 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
4302: 0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
4303: error</a>.</p>
1.1 mike 4304:
4305: </dd>
4306:
4307:
4308: <dt>Anything else</dt>
4309:
4310: <dd>
4311:
4312: <p>Consume the maximum number of characters possible, with the
4313: consumed characters matching one of the identifiers in the first
4314: column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
4315: <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
4316:
1.897 mike 4317: <p>If no match can be made, then no characters are consumed, and
4318: nothing is returned. In this case, if the characters after the
4319: U+0026 AMPERSAND character (&) consist of a sequence of one or
4320: more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
4321: NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
4322: Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL
4323: LETTER Z, followed by a U+003B SEMICOLON character (;), then this
4324: is a <a href="#parse-error">parse error</a>.</p>
1.1 mike 4325:
4326: <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
4327: attribute</a>, and the last character matched is not a U+003B
1.896 mike 4328: SEMICOLON character (;), and the next character is either a U+003D
4329: EQUALS SIGN character (=) or in the range U+0030 DIGIT ZERO (0) to
4330: U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+005A
4331: LATIN CAPITAL LETTER Z, or U+0061 LATIN SMALL LETTER A to U+007A
4332: LATIN SMALL LETTER Z, then, for historical reasons, all the
4333: characters that were matched after the U+0026 AMPERSAND character
4334: (&) must be unconsumed, and nothing is returned.</p>
4335: <!-- "=" added because of http://www.w3.org/Bugs/Public/show_bug.cgi?id=9207#c5 -->
1.1 mike 4336:
1.897 mike 4337: <p>Otherwise, a character reference is parsed. If the last
4338: character matched is not a U+003B SEMICOLON character (;), there
4339: is a <a href="#parse-error">parse error</a>.</p>
4340:
4341: <p>Return a character token for the character corresponding to the
4342: character reference name (as given by the second column of the
4343: <a href="named-character-references.html#named-character-references">named character references</a> table).</p>
1.1 mike 4344:
4345: <div class="example">
4346:
1.897 mike 4347: <p>If the markup contains (not in an attribute) the string <code title="">I'm &notit; I tell you</code>, the character
4348: reference is parsed as "not", as in, <code title="">I'm ¬it;
4349: I tell you</code> (and this is a parse error). But if the markup
1.1 mike 4350: was <code title="">I'm &notin; I tell you</code>, the
4351: character reference would be parsed as "notin;", resulting in
1.897 mike 4352: <code title="">I'm ∉ I tell you</code> (and no parse
4353: error).</p>
1.1 mike 4354:
4355: </div>
4356:
4357: </dd>
4358:
1.266 mike 4359: </dl></div><div class="impl">
4360:
1.363 mike 4361: <!-- v2: One thing that this doesn't define is handling deeply
4362: nested documents. There are compatibility requirements around that:
4363: you can't throw away the elements altogether, consider Tux made only
4364: with opening <font> elements, one per character. Seems that the best
4365: thing to do is to close some formatting elements from the middle of
4366: the stack when you hit a limit, or something. -->
4367:
1.895 mike 4368: <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 4369:
4370: <p>The input to the tree construction stage is a sequence of tokens
4371: from the <a href="#tokenization">tokenization</a> stage. The tree construction
1.810 mike 4372: stage is associated with a DOM <code><a href="infrastructure.html#document">Document</a></code> object when a
1.1 mike 4373: parser is created. The "output" of this stage consists of
4374: dynamically modifying or extending that document's DOM tree.</p>
4375:
4376: <p>This specification does not define when an interactive user agent
1.810 mike 4377: has to render the <code><a href="infrastructure.html#document">Document</a></code> so that it is available to
1.1 mike 4378: the user, or when it has to begin accepting user input.</p>
4379:
4380: <p>As each token is emitted from the tokenizer, the user agent must
4381: process the token according to the rules given in the section
4382: corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
4383:
4384: <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
4385: character</dfn> into a node, if that node has a child immediately
4386: before where the character is to be inserted, and that child is a
1.882 mike 4387: <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 4388: node that the parser inserted into the document, then the character
1.882 mike 4389: must be appended to that <code><a href="infrastructure.html#text">Text</a></code> node; otherwise, a new
4390: <code><a href="infrastructure.html#text">Text</a></code> node whose data is just that character must be
1.1 mike 4391: inserted in the appropriate place.</p>
4392:
4393: <div class="example">
4394:
4395: <p>Here are some sample inputs to the parser and the corresponding
4396: number of text nodes that they result in, assuming a user agent
4397: that executes scripts.</p>
4398:
4399: <table><thead><tr><th>Input </th><th>Number of text nodes
4400: </th></tr></thead><tbody><tr><td><pre>A<script>
4401: var script = document.getElementsByTagName('script')[0];
4402: document.body.removeChild(script);
4403: </script>B</pre>
4404: </td><td>Two adjacent text nodes in the document, containing "A" and "B".
4405: </td></tr><tr><td><pre>A<script>
4406: var text = document.createTextNode('B');
4407: document.body.appendChild(text);
4408: </script>C</pre>
4409: </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
4410: </td></tr><tr><td><pre>A<script>
4411: var text = document.getElementsByTagName('script')[0].firstChild;
4412: text.data = 'B';
4413: document.body.appendChild(text);
4414: </script>B</pre>
4415: </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
4416: </td></tr><tr><td><pre>A<table>B<tr>C</tr>C</table></pre>
4417: </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>.)
4418: </td></tr><tr><td><pre>A<table><tr> B</tr> B</table></pre>
4419: </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>.)
4420: </td></tr><tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
4421: </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.)
4422: </td></tr></tbody></table></div>
4423:
4424: <p id="mutation-during-parsing">DOM mutation events must not fire
4425: for changes caused by the UA parsing the document. (Conceptually,
4426: the parser is not mutating the DOM, it is constructing it.) This
1.159 mike 4427: 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 4428:
4429: <p class="note">Not all of the tag names mentioned below are
4430: conformant tag names in this specification; many are included to
4431: handle legacy content. They still form part of the algorithm that
4432: implementations are required to implement to claim conformance.</p>
4433:
4434: <p class="note">The algorithm described below places no limit on the
4435: depth of the DOM tree generated, or on the length of tag names,
4436: attribute names, attribute values, text nodes, etc. While
4437: implementors are encouraged to avoid arbitrary limits, it is
4438: recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445 mike 4439: concerns</a> will likely force user agents to impose nesting depth
4440: constraints.</p>
1.1 mike 4441:
4442:
1.895 mike 4443: <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 4444:
4445: <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
4446: element for the token">create an element for a token</dfn> in a
4447: particular namespace, the UA must create a node implementing the
4448: interface appropriate for the element type corresponding to the tag
4449: name of the token in the given namespace (as given in the
4450: 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 4451: element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, this specification
1.1 mike 4452: defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
4453: the tag name being the name of that element, with the node being in
4454: the given namespace, and with the attributes on the node being those
4455: given in the given token.</p>
4456:
1.724 mike 4457: <p>The interface appropriate for an element in the <a href="infrastructure.html#html-namespace-0">HTML
1.426 mike 4458: namespace</a> that is not defined in this specification (or
4459: <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44 mike 4460: <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1 mike 4461: interface is not defined by that namespace's specification must use
1.810 mike 4462: the interface <code><a href="infrastructure.html#element">Element</a></code>.</p>
1.1 mike 4463:
1.882 mike 4464: <p>When a <a href="forms.html#category-reset" title="category-reset">resettable element</a> is
1.1 mike 4465: created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
4466: invoked once the attributes are set. (This initializes the element's
4467: <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
4468: attributes.)</p>
4469:
4470: <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
4471: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
1.724 mike 4472: for the token</a> in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, and then
1.1 mike 4473: append this node to the <a href="#current-node">current node</a>, and push it onto
4474: the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
4475: <a href="#current-node">current node</a>.</p>
4476:
4477: <p>The steps below may also require that the UA insert an HTML
4478: element in a particular place, in which case the UA must follow the
4479: same steps except that it must insert or append the new node in the
4480: location specified instead of appending it to the <a href="#current-node">current
4481: node</a>. (This happens in particular during the parsing of
4482: tables with invalid content.)</p>
4483:
4484: <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
4485: algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
4486: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
4487: 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
4488: <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
4489: created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
4490: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
4491: inserting it wherever it is to be inserted.</p>
4492:
4493: <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
4494: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
4495: for the token</a> in the given namespace, and then append this
4496: node to the <a href="#current-node">current node</a>, and push it onto the
4497: <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
1.724 mike 4498: <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 4499: whose value is not exactly the same as the element's namespace, that
4500: is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
4501: element has an <code title="">xmlns:xlink</code> attribute in the
1.724 mike 4502: <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="infrastructure.html#xlink-namespace">XLink
1.1 mike 4503: Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
4504:
4505: <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
4506: attributes</dfn> for a token, then, if the token has an attribute
4507: named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
4508:
4509: <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
4510: attributes</dfn> for a token, then, for each attribute on the token
4511: whose attribute name is one of the ones in the first column of the
4512: following table, change the attribute's name to the name given in
4513: the corresponding cell in the second column. (This fixes the case of
4514: SVG attributes that are not all lowercase.)</p>
4515:
4516: <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
4517: </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
4518: </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
4519: </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
4520: </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
4521: </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
4522: </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
4523: </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
4524: </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
4525: </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
4526: </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
4527: </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
4528: </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
4529: </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
4530: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
4531: </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
4532: </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
4533: </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
4534: </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
4535: </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
4536: </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
4537: </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
4538: </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
4539: </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
4540: </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
4541: </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
4542: </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
4543: </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
4544: </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
4545: </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
4546: </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
4547: </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
4548: </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
4549: </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
4550: </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
4551: </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
4552: </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
4553: </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
4554: </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
4555: </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
4556: </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
4557: </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
4558: </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
4559: </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
4560: </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
4561: </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
4562: </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
4563: </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
4564: </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
4565: </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
4566: </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
4567: </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
4568: </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
4569: </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
4570: </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
4571: </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
4572: </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
4573: </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
4574: </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
4575: </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
4576: </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
4577: </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
4578: </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
4579: </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
4580: foreign attributes</dfn> for a token, then, if any of the attributes
4581: on the token match the strings given in the first column of the
4582: following table, let the attribute be a namespaced attribute, with
4583: the prefix being the string given in the corresponding cell in the
4584: second column, the local name being the string given in the
4585: corresponding cell in the third column, and the namespace being the
4586: namespace given in the corresponding cell in the fourth
4587: column. (This fixes the use of namespaced attributes, in particular
4588: <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
4589: the <span>XML namespace</span></a>.)</p>
4590:
4591: <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
1.724 mike 4592: </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>
4593: </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>
4594: </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>
4595: </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>
4596: </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>
4597: </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>
4598: </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>
4599: </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 -->
4600: </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>
4601: </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>
4602: </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>
4603: </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 4604: </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 4605: <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
4606: following steps. These algorithms are always invoked in response to
4607: a start tag token.</p>
4608:
4609: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
4610:
1.91 mike 4611: <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541 mike 4612: text element parsing algorithm</a>, switch the tokenizer to the
4613: <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
4614: was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
4615: switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1 mike 4616:
4617: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
4618: <a href="#insertion-mode">insertion mode</a>.</p>
4619:
1.540 mike 4620: </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 4621:
1.895 mike 4622: </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 4623:
4624: <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
4625: tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422 mike 4626: <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 4627: <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
4628: <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
4629: <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
4630: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4631: elements</a>.</p>
4632:
4633: <p>If a step requires the UA to generate implied end tags but lists
4634: an element to exclude from the process, then the UA must perform the
4635: above steps as if that element was not in the above list.</p>
4636:
4637:
1.895 mike 4638: <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 4639:
4640: <p>Foster parenting happens when content is misnested in tables.</p>
4641:
4642: <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
4643: parent">foster parented</dfn>, the node <var title="">node</var>
4644: must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4645:
4646: <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
4647: 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
4648: elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
4649: such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4650: the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
4651: case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
4652: element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159 mike 4653: <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1 mike 4654: <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
4655: elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4656: <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
4657: node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
4658: the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4659: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
4660:
4661: <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
4662: 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
4663: elements</a>, then <var title="">node</var> must be inserted
4664: immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4665: the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
4666: element</a></i>; otherwise, <var title="">node</var> must be
4667: <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4668:
4669:
4670:
1.895 mike 4671: <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 4672:
4673: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
4674: mode: initial">initial</a>", tokens must be handled as follows:</p>
4675:
4676: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4677: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 4678: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 4679: <dd>
4680: <p>Ignore the token.</p>
4681: </dd>
4682:
4683: <dt>A comment token</dt>
4684: <dd>
1.882 mike 4685: <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 4686: object with the <code title="">data</code> attribute set to the
4687: data given in the comment token.</p>
4688: </dd>
4689:
4690: <dt>A DOCTYPE token</dt>
4691: <dd>
4692:
4693: <p>If the DOCTYPE token's name is not a
4694: <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
4695: missing, or the token's system identifier is neither missing nor a
4696: <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465 mike 4697: "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1 mike 4698: conditions in the following list are matched, then there is a
1.861 mike 4699: <a href="#parse-error">parse error</a>.</p>
1.1 mike 4700:
4701: <ul><!-- only things that trigger no-quirks mode and were valid in
1.688 mike 4702: 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>
4703: match for the string "<code title="">html</code>", the token's
4704: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4705: "<code title="">-//W3C//DTD HTML 4.0//EN</code>", and
4706: the token's system identifier is either missing or the
1.1 mike 4707: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
4708:
1.688 mike 4709: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4710: match for the string "<code title="">html</code>", the token's
4711: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4712: "<code title="">-//W3C//DTD HTML 4.01//EN</code>", and
4713: the token's system identifier is either missing or the
1.1 mike 4714: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
4715:
1.688 mike 4716: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4717: match for the string "<code title="">html</code>", the token's
4718: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4719: "<code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>",
1.1 mike 4720: and the token's system identifier is the
4721: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
4722:
1.688 mike 4723: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4724: match for the string "<code title="">html</code>", the token's
4725: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4726: "<code title="">-//W3C//DTD XHTML 1.1//EN</code>", and
4727: the token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
1.1 mike 4728: string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
4729:
4730: </ul><p>Conformance checkers may, based on the values (including
4731: presence or lack thereof) of the DOCTYPE token's name, public
4732: identifier, or system identifier, switch to a conformance checking
4733: mode for another language (e.g. based on the DOCTYPE token a
4734: conformance checker could recognize that the document is an
1.183 mike 4735: HTML4-era document, and defer to an HTML4 conformance
1.1 mike 4736: checker.)</p>
4737:
1.882 mike 4738: <p>Append a <code><a href="infrastructure.html#documenttype">DocumentType</a></code> node to the
1.810 mike 4739: <code><a href="infrastructure.html#document">Document</a></code> node, with the <code title="">name</code>
1.1 mike 4740: attribute set to the name given in the DOCTYPE token, or the empty
4741: string if the name was missing; the <code title="">publicId</code>
4742: attribute set to the public identifier given in the DOCTYPE token,
4743: or the empty string if the public identifier was missing; the
4744: <code title="">systemId</code> attribute set to the system
4745: identifier given in the DOCTYPE token, or the empty string if the
4746: system identifier was missing; and the other attributes specific
1.882 mike 4747: to <code><a href="infrastructure.html#documenttype">DocumentType</a></code> objects set to null and empty lists
4748: as appropriate. Associate the <code><a href="infrastructure.html#documenttype">DocumentType</a></code> node with
1.810 mike 4749: the <code><a href="infrastructure.html#document">Document</a></code> object so that it is returned as the
1.1 mike 4750: value of the <code title="">doctype</code> attribute of the
1.810 mike 4751: <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4752:
4753: <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
4754: one of the conditions in the following list, then set the
1.810 mike 4755: <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
1.1 mike 4756:
4757: <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
1.688 mike 4758: <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 4759: <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
4760: <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4761: <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4762: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
4763: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
4764: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
4765: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
4766: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
4767: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
4768: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
4769: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
4770: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
4771: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4772: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
4773: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
4774: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
4775: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
4776: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
4777: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
4778: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
4779: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
4780: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
4781: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
4782: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
4783: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
4784: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
4785: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
4786: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
4787: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
4788: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
4789: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
4790: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
4791: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
4792: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
4793: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
4794: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
4795: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
4796: <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
4797: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
4798: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
4799: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
4800: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
4801: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
4802: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
4803: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
4804: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
4805: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
4806: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
4807: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
4808: <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
4809: <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
4810: <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
4811: <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
4812: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
4813: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
4814: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
4815: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
4816: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4817: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
4818: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
4819: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
4820: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
4821: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
4822: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
4823: <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
4824: <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
4825: <!--<li> The public identifier is set to: "<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 Strict 3.0//EN//</code>" </li>
4827: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
4828: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
4829: <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
4830: <li> The public identifier is set to: "<code title="">HTML</code>" </li>
4831: <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
4832: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4833: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
4834: </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
1.810 mike 4835: in the following list, then set the <code><a href="infrastructure.html#document">Document</a></code> to
1.880 mike 4836: <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>:</p>
1.1 mike 4837:
4838: <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
4839: <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
4840: <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4841: <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 4842: </ul><p>The system identifier and public identifier strings must be
4843: compared to the values given in the lists above in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
4844: case-insensitive</a> manner. A system identifier whose value is
4845: the empty string is not considered missing for the purposes of the
4846: conditions above.</p>
1.1 mike 4847:
4848: <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>
4849:
4850: </dd>
4851:
4852: <dt>Anything else</dt>
4853: <dd>
4854:
1.727 mike 4855: <p>If the document is <em>not</em> <a href="text-level-semantics.html#an-iframe-srcdoc-document">an <code>iframe</code>
4856: <code title="attr-iframe-srcdoc">srcdoc</code> document</a>,
4857: then this is a <a href="#parse-error">parse error</a>; set the
1.810 mike 4858: <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
1.1 mike 4859:
1.727 mike 4860: <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 4861: reprocess the current token.</p>
4862:
4863: </dd>
4864:
1.895 mike 4865: </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 4866:
4867: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
4868: mode: before html">before html</a>", tokens must be handled as follows:</p>
4869:
4870: <dl class="switch"><dt>A DOCTYPE token</dt>
4871: <dd>
4872: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4873: </dd>
4874:
4875: <dt>A comment token</dt>
4876: <dd>
1.882 mike 4877: <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 4878: object with the <code title="">data</code> attribute set to the
4879: data given in the comment token.</p>
4880: </dd>
4881:
4882: <dt>A character token that is one of U+0009 CHARACTER
4883: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 4884: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 4885: <dd>
4886: <p>Ignore the token.</p>
4887: </dd>
4888:
4889: <dt>A start tag whose tag name is "html"</dt>
4890: <dd>
4891:
1.724 mike 4892: <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 4893: namespace</a>. Append it to the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 4894: object. Put this element in the <a href="#stack-of-open-elements">stack of open
4895: elements</a>.</p>
4896:
1.810 mike 4897: <p id="parser-appcache">If the <code><a href="infrastructure.html#document">Document</a></code> is being
1.1 mike 4898: loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
4899: <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
1.875 mike 4900: has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute
4901: whose value is not the empty string, then <a href="infrastructure.html#resolve-a-url" title="resolve a
4902: url">resolve</a> the value of that attribute to an
4903: <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly created element,
4904: and if that is successful, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
1.29 mike 4905: algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
4906: any <a href="infrastructure.html#url-fragment" title="url-fragment"><fragment></a> component
1.875 mike 4907: removed; otherwise, if there is no such attribute, or its value is
4908: the empty string, or resolving its value fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
4909: algorithm</a> with no manifest. The algorithm must be passed
4910: the <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4911:
4912: <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>
4913:
4914: </dd>
4915:
1.334 mike 4916: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4917: <dd>
4918: <p>Act as described in the "anything else" entry below.</p>
4919: </dd>
4920:
4921: <dt>Any other end tag</dt>
4922: <dd>
4923: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4924: </dd>
4925:
1.1 mike 4926: <dt>Anything else</dt>
4927: <dd>
4928:
1.159 mike 4929: <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.810 mike 4930: <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 4931: of open elements</a>.</p>
4932:
1.810 mike 4933: <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 4934: context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
4935: algorithm</a> with no manifest, passing it the
1.810 mike 4936: <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4937:
4938: <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
4939: reprocess the current token.</p>
4940:
4941: </dd>
4942:
4943: </dl><p>The root element can end up being removed from the
1.810 mike 4944: <code><a href="infrastructure.html#document">Document</a></code> object, e.g. by scripts; nothing in particular
1.1 mike 4945: happens in such cases, content continues being appended to the nodes
4946: as described in the next section.</p>
4947:
4948:
1.895 mike 4949: <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 4950:
4951: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
4952: mode: before head">before head</a>", tokens must be handled as follows:</p>
4953:
4954: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4955: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 4956: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 4957: <dd>
4958: <p>Ignore the token.</p> <!-- :-( -->
4959: </dd>
4960:
4961: <dt>A comment token</dt>
4962: <dd>
1.882 mike 4963: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 4964: node</a> with the <code title="">data</code> attribute set to
4965: the data given in the comment token.</p>
4966: </dd>
4967:
4968: <dt>A DOCTYPE token</dt>
4969: <dd>
4970: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4971: </dd>
4972:
4973: <dt>A start tag whose tag name is "html"</dt>
4974: <dd>
4975: <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
4976: mode</a>.</p>
4977: </dd>
4978:
4979: <dt>A start tag whose tag name is "head"</dt>
4980: <dd>
4981:
4982: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
4983:
4984: <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159 mike 4985: to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 4986:
4987: <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>
4988:
4989: </dd>
4990:
4991: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4992: <dd>
4993:
4994: <p>Act as if a start tag token with the tag name "head" and no
4995: attributes had been seen, then reprocess the current token.</p>
4996:
4997: </dd>
4998:
4999: <dt>Any other end tag</dt>
5000: <dd>
5001:
5002: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5003:
5004: </dd>
5005:
5006: <dt>Anything else</dt>
5007: <dd>
5008:
5009: <p>Act as if a start tag token with the tag name "head" and no
5010: attributes had been seen, then reprocess the current
5011: token.</p>
5012:
5013: </dd>
5014:
1.895 mike 5015: </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 5016:
5017: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
5018: mode: in head">in head</a>", tokens must be handled as follows:</p>
5019:
5020: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
5021: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 5022: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 5023: <dd>
5024: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
5025: the <a href="#current-node">current node</a>.</p>
5026: </dd>
5027:
5028: <dt>A comment token</dt>
5029: <dd>
1.882 mike 5030: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 5031: node</a> with the <code title="">data</code> attribute set to
5032: the data given in the comment token.</p>
5033: </dd>
5034:
5035: <dt>A DOCTYPE token</dt>
5036: <dd>
5037: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5038: </dd>
5039:
5040: <dt>A start tag whose tag name is "html"</dt>
5041: <dd>
5042: <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
5043: mode</a>.</p>
5044: </dd>
5045:
5046: <dt>A start tag whose tag name is one of: "base", "command",
5047: "link"</dt>
5048: <dd>
5049:
5050: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5051: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
5052: elements</a>.</p>
5053:
5054: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
5055: token's <i>self-closing flag</i></a>, if it is set.</p>
5056:
5057: </dd>
5058:
5059: <dt>A start tag whose tag name is "meta"</dt>
5060: <dd>
5061:
5062: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5063: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
5064: elements</a>.</p>
5065:
5066: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
5067: token's <i>self-closing flag</i></a>, if it is set.</p>
5068:
5069: <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
5070: value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
5071: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
5072: encoding</a> to the encoding given by the value of the
5073: <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
5074:
1.924 mike 5075: <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
5076: value is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the
5077: string "<code title="">Content-Type</code>", and the element has a
5078: <code title="attr-meta-content"><a href="semantics.html#attr-meta-content">content</a></code> attribute, and
1.1 mike 5079: 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 5080: Content-Type</a> to that attribute's value returns a supported
5081: encoding <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is currently
5082: <i>tentative</i>, then <a href="#change-the-encoding">change the encoding</a> to the
5083: encoding <var title="">encoding</var>.</p>
1.1 mike 5084:
5085: </dd>
5086:
5087: <dt>A start tag whose tag name is "title"</dt>
5088: <dd>
5089: <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
5090: </dd>
5091:
5092: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
5093: <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
5094: <dd>
1.91 mike 5095: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 5096: </dd>
5097:
5098: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
5099: <dd>
5100:
5101: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5102:
5103: <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
5104: noscript</a>".</p>
5105:
5106: </dd>
5107:
5108: <dt id="scriptTag">A start tag whose tag name is "script"</dt>
5109: <dd>
5110:
1.854 mike 5111: <p>Run these steps:</p>
5112:
1.1 mike 5113: <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
1.724 mike 5114: <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</p></li>
1.1 mike 5115:
5116: <li>
5117:
5118: <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
5119:
5120: <p class="note">This ensures that, if the script is external,
1.159 mike 5121: any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1 mike 5122: calls in the script will execute in-line, instead of blowing the
5123: document away, as would happen in most other cases. It also
5124: prevents the script from executing until the end tag is
5125: seen.</p>
5126:
5127: </li>
5128:
5129: <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
5130: fragment parsing algorithm</a>, then mark the
1.484 mike 5131: <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
5132: started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1 mike 5133:
5134: <li><p>Append the new element to the <a href="#current-node">current node</a>
5135: and push it onto the <a href="#stack-of-open-elements">stack of open
5136: elements</a>.</p></li>
5137:
1.541 mike 5138: <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
5139: state</a>.</p></li>
1.1 mike 5140:
5141: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
5142: <a href="#insertion-mode">insertion mode</a>.</p>
5143:
1.540 mike 5144: </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 5145:
5146: </ol></dd>
5147:
5148: <dt>An end tag whose tag name is "head"</dt>
5149: <dd>
5150:
5151: <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159 mike 5152: <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 5153: elements</a>.</p>
5154:
5155: <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>
5156:
5157: </dd>
5158:
5159: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5160: <dd>
5161: <p>Act as described in the "anything else" entry below.</p>
5162: </dd>
5163:
5164: <dt>A start tag whose tag name is "head"</dt>
5165: <dt>Any other end tag</dt>
5166: <dd>
5167: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5168: </dd>
5169:
5170: <dt>Anything else</dt>
5171: <dd>
5172:
5173: <!-- can't get here with an EOF and a fragment case -->
5174:
5175: <p>Act as if an end tag token with the tag name "head" had
5176: been seen, and reprocess the current token.</p>
5177:
5178: </dd>
5179:
1.895 mike 5180: </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 5181:
5182: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
5183: mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
5184:
5185: <dl class="switch"><dt>A DOCTYPE token</dt>
5186: <dd>
5187: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5188: </dd>
5189:
5190: <dt>A start tag whose tag name is "html"</dt>
5191: <dd>
5192: <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
5193: mode</a>.</p>
5194: </dd>
5195:
5196: <dt>An end tag whose tag name is "noscript"</dt>
5197: <dd>
5198:
5199: <p>Pop the <a href="#current-node">current node</a> (which will be a
5200: <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
5201: elements</a>; the new <a href="#current-node">current node</a> will be a
1.159 mike 5202: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 5203:
5204: <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>
5205:
5206: </dd>
5207:
5208: <dt>A character token that is one of U+0009 CHARACTER
5209: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 5210: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 5211: <dt>A comment token</dt>
5212: <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
5213: <dd>
5214: <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
5215: mode</a>.</p>
5216: </dd>
5217:
5218: <dt>An end tag whose tag name is "br"</dt>
5219: <dd>
5220: <p>Act as described in the "anything else" entry below.</p>
5221: </dd>
5222:
5223: <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
5224: <dt>Any other end tag</dt>
5225: <dd>
5226: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5227: </dd>
5228:
5229: <dt>Anything else</dt>
5230: <dd>
5231:
5232: <!-- can't get here with an EOF and a fragment case -->
5233:
5234: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
5235: name "noscript" had been seen and reprocess the current
5236: token.</p>
5237:
5238: </dd>
5239:
1.895 mike 5240: </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 5241:
5242: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
5243: mode: after head">after head</a>", tokens must be handled as follows:</p>
5244:
5245: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
5246: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 5247: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 5248: <dd>
5249: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
5250: the <a href="#current-node">current node</a>.</p>
5251: </dd>
5252:
5253: <dt>A comment token</dt>
5254: <dd>
1.882 mike 5255: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 5256: node</a> with the <code title="">data</code> attribute set to
5257: the data given in the comment token.</p>
5258: </dd>
5259:
5260: <dt>A DOCTYPE token</dt>
5261: <dd>
5262: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5263: </dd>
5264:
5265: <dt>A start tag whose tag name is "html"</dt>
5266: <dd>
5267: <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
5268: mode</a>.</p>
5269: </dd>
5270:
5271: <dt>A start tag whose tag name is "body"</dt>
5272: <dd>
5273:
5274: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5275:
5276: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5277:
5278: <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>
5279:
5280: </dd>
5281:
5282: <dt>A start tag whose tag name is "frameset"</dt>
5283: <dd>
5284:
5285: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5286:
5287: <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>
5288:
5289: </dd>
5290:
5291: <dt>A start tag token whose tag name is one of: "base", "link",
5292: "meta", "noframes", "script", "style", "title"</dt>
5293: <dd>
5294:
5295: <p><a href="#parse-error">Parse error</a>.</p>
5296:
5297: <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
5298: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5299:
5300: <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
5301: mode</a>.</p>
5302:
5303: <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
5304: of open elements</a>.</p>
5305:
5306: <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
5307: pointer</a> cannot be null at this point.</p>
5308:
5309: </dd>
5310:
5311: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5312: <dd>
5313: <p>Act as described in the "anything else" entry below.</p>
5314: </dd>
5315:
5316: <dt>A start tag whose tag name is "head"</dt>
5317: <dt>Any other end tag</dt>
5318: <dd>
5319: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5320: </dd>
5321:
5322: <dt>Anything else</dt>
5323: <dd>
5324: <p>Act as if a start tag token with the tag name "body" and no
5325: attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
5326: flag</a> back to "ok", and then reprocess the current
5327: token.</p>
5328: </dd>
5329:
1.895 mike 5330: </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 5331:
5332: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
5333: mode: in body">in body</a>", tokens must be handled as follows:</p>
5334:
5335: <dl class="switch"><dt>A character token</dt>
5336: <dd>
5337:
5338: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5339: any.</p>
5340:
5341: <p><a href="#insert-a-character" title="insert a character">Insert the token's
5342: character</a> into the <a href="#current-node">current node</a>.</p>
5343:
5344: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
1.882 mike 5345: LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN
5346: (CR), or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
1.1 mike 5347: flag</a> to "not ok".</p>
5348:
5349: </dd>
5350:
5351: <dt>A comment token</dt>
5352: <dd>
1.882 mike 5353: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 5354: node</a> with the <code title="">data</code> attribute set to
5355: the data given in the comment token.</p>
5356: </dd>
5357:
5358: <dt>A DOCTYPE token</dt>
5359: <dd>
5360: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5361: </dd>
5362:
5363: <dt>A start tag whose tag name is "html"</dt>
5364: <dd>
5365: <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
5366: check to see if the attribute is already present on the top
5367: element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
5368: add the attribute and its corresponding value to that element.</p>
5369: </dd>
5370:
5371: <dt>A start tag token whose tag name is one of: "base", "command",
5372: "link", "meta", "noframes", "script", "style", "title"</dt>
5373: <dd>
5374: <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
5375: mode</a>.</p>
5376: </dd>
5377:
5378: <dt>A start tag whose tag name is "body"</dt>
5379: <dd>
5380:
5381: <p><a href="#parse-error">Parse error</a>.</p>
5382:
5383: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5384: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5385: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5386: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5387:
5388: <p>Otherwise, for each attribute on the token, check to see if
1.159 mike 5389: the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 5390: element (the second element) on the <a href="#stack-of-open-elements">stack of open
5391: elements</a>. If it is not, add the attribute and its
5392: corresponding value to that element.</p>
5393:
5394: </dd>
5395:
5396: <dt>A start tag whose tag name is "frameset"</dt>
5397: <dd>
5398:
5399: <p><a href="#parse-error">Parse error</a>.</p>
5400:
5401: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5402: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5403: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5404: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5405:
5406: <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
5407: the token.</p>
5408:
5409: <p>Otherwise, run the following steps:</p>
5410:
5411: <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
5412: elements</a> from its parent node, if it has one.</p></li>
5413:
5414: <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
5415: open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159 mike 5416: but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1 mike 5417:
5418: </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
5419: token.</p></li>
5420:
5421: <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>
5422:
5423: </li></ol></dd>
5424:
5425: <dt>An end-of-file token</dt>
5426: <dd>
5427:
5428: <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422 mike 5429: 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>
5430: 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 5431: <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
5432: <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
5433: <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 5434: <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 5435: this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422 mike 5436: fragment cases) -->
1.1 mike 5437:
5438: <p><a href="#stop-parsing">Stop parsing</a>.</p>
5439:
5440: </dd>
5441:
5442: <dt>An end tag whose tag name is "body"</dt>
5443: <dd>
5444:
5445: <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
5446: in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
5447: token.</p>
5448:
5449: <!-- if we get here, the insertion mode here is forcibly "in
5450: body". -->
5451:
5452: <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422 mike 5453: elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1 mike 5454: <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
5455: <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
5456: <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
5457: <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
5458: <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
5459: <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 5460: <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
5461: <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 5462: error</a>.</p> <!-- (some of those are fragment cases, e.g. for
5463: <tbody> you'd have hit the first paragraph since the <body>
1.422 mike 5464: wouldn't be in scope, unless it was a fragment case) -->
1.1 mike 5465:
5466: <!-- If we ever change the frameset-ok flag to an insertion mode,
5467: then we'd have to somehow keep track of its state when we switch
5468: to after-body. -->
5469:
5470: <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>
5471:
5472: </dd>
5473:
5474: <dt>An end tag whose tag name is "html"</dt>
5475: <dd>
5476:
5477: <p>Act as if an end tag with tag name "body" had been seen,
5478: then, if that token wasn't ignored, reprocess the current
5479: token.</p>
5480:
5481: </dd>
5482:
5483: <!-- start tags for non-phrasing flow content elements -->
5484:
5485: <!-- the normal ones -->
5486: <dt>A start tag whose tag name is one of: "address", "article",
1.683 mike 5487: "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305 mike 5488: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5489: "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1 mike 5490: <dd>
5491:
5492: <!-- As of May 2008 this doesn't match any browser exactly, but is
5493: as close to what IE does as I can get without doing the non-tree
5494: DOM nonsense, and thus should actually afford better compatibility
5495: when implemented by the other browsers. -->
5496:
5497: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5498: an element in scope">has a <code>p</code> element in
5499: scope</a>, then act as if an end tag with the tag name
5500: "p" had been seen.</p>
5501:
5502: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5503:
5504: </dd>
5505:
5506: <!-- as normal, but close h1-h6 if it's the current node -->
5507: <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
5508: "h5", "h6"</dt>
5509: <dd>
5510:
5511: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5512: an element in scope">has a <code>p</code> element in
5513: scope</a>, then act as if an end tag with the tag name
5514: "p" had been seen.</p>
5515:
5516: <p>If the <a href="#current-node">current node</a> is an element whose tag name
5517: is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
5518: <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
5519: the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5520: <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
5521:
5522: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5523:
5524: </dd>
5525:
5526: <!-- as normal, but drops leading newline -->
5527: <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
5528: <dd>
5529:
5530: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5531: an element in scope">has a <code>p</code> element in
5532: scope</a>, then act as if an end tag with the tag name
5533: "p" had been seen.</p>
5534:
5535: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5536:
5537: <p>If the next token is a U+000A LINE FEED (LF) character
5538: token, then ignore that token and move on to the next
5539: one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
5540: ignored as an authoring convenience.)</p>
5541:
1.882 mike 5542: <!-- <pre>[CR]X will eat the [CR], <pre>X will eat the
5543: , but <pre>X will not eat the . -->
5544:
1.1 mike 5545: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5546:
5547: </dd>
5548:
5549: <!-- as normal, but interacts with the form element pointer -->
5550: <dt>A start tag whose tag name is "form"</dt>
5551: <dd>
5552:
5553: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
5554: pointer</a> is not null, then this is a <a href="#parse-error">parse
5555: error</a>; ignore the token.</p>
5556:
5557: <p>Otherwise:</p>
5558:
5559: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5560: an element in scope">has a <code>p</code> element in
5561: scope</a>, then act as if an end tag with the tag name
5562: "p" had been seen.</p>
5563:
5564: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
5565: <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
5566: point to the element created.</p>
5567:
5568: </dd>
5569:
5570: <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
5571: <dt>A start tag whose tag name is "li"</dt>
5572: <dd>
5573:
1.864 mike 5574: <p>Run these steps:</p>
1.1 mike 5575:
5576: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5577:
5578: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5579: node</a> (the bottommost node of the stack).</p></li>
5580:
1.578 mike 5581: <li><p><i>Loop</i>: If <var title="">node</var> is an
5582: <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
5583: name "li" had been seen, then jump to the last step.</p></li>
1.1 mike 5584:
1.578 mike 5585: <li><p>If <var title="">node</var> is not in the
1.1 mike 5586: <a href="#formatting">formatting</a> category, and is not in the
5587: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5588: <code><a href="semantics.html#the-address-element">address</a></code>, <code><a href="semantics.html#the-div-element">div</a></code>, or <code><a href="semantics.html#the-p-element">p</a></code>
1.1 mike 5589: element, then jump to the last step.</p></li> <!-- an element
5590: <foo> is in this list if the following markup:
5591:
5592: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
5593:
5594: ...results in the second <li> not being (in any way) a descendant
5595: of the first <li>, or if <foo> is a formatting element that gets
5596: reopened later. -->
5597:
5598: <li><p>Otherwise, set <var title="">node</var> to the previous
5599: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5600: the step labeled <i>loop</i>.</p></li>
5601:
5602: <li>
5603:
5604: <p>This is the last step.</p>
5605:
5606: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5607: an element in scope">has a <code>p</code> element in
5608: scope</a>, then act as if an end tag with the tag name
5609: "p" had been seen.</p>
5610:
5611: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5612: token.</p>
5613:
5614: </li>
5615:
5616: </ol></dd>
5617:
5618: <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases -->
1.422 mike 5619: <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5620: <dd>
5621:
1.854 mike 5622: <p>Run these steps:</p>
1.1 mike 5623:
5624: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5625:
5626: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5627: node</a> (the bottommost node of the stack).</p></li>
5628:
5629: <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422 mike 5630: <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
5631: tag with the same tag name as <var title="">node</var> had been
5632: seen, then jump to the last step.</p></li>
1.1 mike 5633:
5634: <li><p>If <var title="">node</var> is not in the
5635: <a href="#formatting">formatting</a> category, and is not in the
5636: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5637: <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 5638: element, then jump to the last step.</p></li> <!-- an element
5639: <foo> is in this list if the following markup:
5640:
5641: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
5642:
5643: ...results in the second <dt> not being (in any way) a descendant
5644: of the first <dt>, or if <foo> is a formatting element that gets
5645: reopened later. -->
5646:
5647: <li><p>Otherwise, set <var title="">node</var> to the previous
5648: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5649: the step labeled <i>loop</i>.</p></li>
5650:
5651: <li>
5652:
5653: <p>This is the last step.</p>
5654:
5655: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5656: an element in scope">has a <code>p</code> element in
5657: scope</a>, then act as if an end tag with the tag name
5658: "p" had been seen.</p>
5659:
5660: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5661: token.</p>
5662:
5663: </li>
5664:
5665: </ol></dd>
5666:
5667: <!-- same as normal, but effectively ends parsing -->
5668: <dt>A start tag whose tag name is "plaintext"</dt>
5669: <dd>
5670:
5671: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5672: an element in scope">has a <code>p</code> element in
5673: scope</a>, then act as if an end tag with the tag name
5674: "p" had been seen.</p>
5675:
5676: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5677:
1.541 mike 5678: <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5679:
1.541 mike 5680: <p class="note">Once a start tag with the tag name "plaintext" has
5681: been seen, that will be the last token ever seen other than
5682: character tokens (and the end-of-file token), because there is no
5683: way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5684:
5685: </dd>
5686:
1.953 mike 5687: <!-- button is a hybrid -->
5688: <dt>A start tag whose tag name is "button"</dt>
5689: <dd>
5690:
5691: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5692: an element in scope">has a <code>button</code> element in
5693: scope</a>, then this is a <a href="#parse-error">parse error</a>;
5694: act as if an end tag with the tag name "button" had been seen,
5695: then reprocess the token.</p>
5696:
5697: <p>Otherwise:</p>
5698:
5699: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5700: any.</p>
5701:
5702: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5703:
5704: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5705:
5706: </dd>
5707:
5708: <!-- end tags for non-phrasing flow content elements (and button) -->
1.1 mike 5709:
5710: <!-- the normal ones -->
5711: <dt>An end tag whose tag name is one of: "address", "article",
1.953 mike 5712: "aside", "blockquote", "button", "center",
5713: <!--v2DATAGRID"datagrid",--> "details", "dir", "div", "dl",
5714: "fieldset", "figure", "footer", "header", "hgroup", "listing",
5715: "menu", "nav", "ol", "pre", "section", "ul"</dt>
1.1 mike 5716: <dd>
5717:
5718: <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>
5719: with the same tag name as that of the token, then this is a
5720: <a href="#parse-error">parse error</a>; ignore the token.</p>
5721:
5722: <p>Otherwise, run these steps:</p>
5723:
5724: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5725:
5726: <li><p>If the <a href="#current-node">current node</a> is not an element with
5727: the same tag name as that of the token, then this is a
5728: <a href="#parse-error">parse error</a>.</p></li>
5729:
5730: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5731: until an element with the same tag name as the token has been
5732: popped from the stack.</p></li>
5733:
5734: </ol></dd>
5735:
5736: <!-- removes the form element pointer instead of the matching node -->
5737: <dt>An end tag whose tag name is "form"</dt>
5738: <dd>
5739:
5740: <p>Let <var title="">node</var> be the element that the
5741: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
5742: to.</p>
5743:
5744: <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
5745: to null.</p>
5746:
5747: <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
5748: elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
5749: scope">have <var title="">node</var> in scope</a>, then this is
5750: a <a href="#parse-error">parse error</a>; ignore the token.</p>
5751:
5752: <p>Otherwise, run these steps:</p>
5753:
5754: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5755:
5756: <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
5757: error</a>.</p></li>
5758:
5759: <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
5760: open elements</a>.</p></li>
5761:
5762: </ol></dd>
5763:
5764: <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
5765: <dt>An end tag whose tag name is "p"</dt>
5766: <dd>
5767:
5768: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-scope" title="has an element in scope">have an element in scope</a>
5769: with the same tag name as that of the token, then this is a
5770: <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
5771: "p" had been seen, then reprocess the current token.</p>
5772:
5773: <p>Otherwise, run these steps:</p>
5774:
5775: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5776: for elements with the same tag name as the token.</p></li>
5777:
5778: <li><p>If the <a href="#current-node">current node</a> is not an element with
5779: the same tag name as that of the token, then this is a
5780: <a href="#parse-error">parse error</a>.</p></li>
5781:
5782: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5783: until an element with the same tag name as the token has been
5784: popped from the stack.</p></li>
5785:
5786: </ol></dd>
5787:
1.234 mike 5788: <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
5789: <dt>An end tag whose tag name is "li"</dt>
5790: <dd>
5791:
5792: <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
5793: item scope</a> with the same tag name as that of the token,
5794: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5795:
5796: <p>Otherwise, run these steps:</p>
5797:
5798: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5799: for elements with the same tag name as the token.</p></li>
5800:
5801: <li><p>If the <a href="#current-node">current node</a> is not an element with
5802: the same tag name as that of the token, then this is a
5803: <a href="#parse-error">parse error</a>.</p></li>
5804:
5805: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5806: until an element with the same tag name as the token has been
5807: popped from the stack.</p></li>
5808:
5809: </ol></dd>
5810:
1.1 mike 5811: <!-- as normal, but needs care as the elements have optional tags -->
1.422 mike 5812: <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5813: <dd>
5814:
5815: <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>
5816: with the same tag name as that of the token, then this is a
5817: <a href="#parse-error">parse error</a>; ignore the token.</p>
5818:
5819: <p>Otherwise, run these steps:</p>
5820:
5821: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5822: for elements with the same tag name as the token.</p></li>
5823:
5824: <li><p>If the <a href="#current-node">current node</a> is not an element with
5825: the same tag name as that of the token, then this is a
5826: <a href="#parse-error">parse error</a>.</p></li>
5827:
5828: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5829: until an element with the same tag name as the token has been
5830: popped from the stack.</p></li>
5831:
5832: </ol></dd>
5833:
5834: <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
5835: <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
5836: <dd>
5837:
5838: <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>
5839: whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
5840: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5841:
5842: <p>Otherwise, run these steps:</p>
5843:
5844: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5845:
5846: <li><p>If the <a href="#current-node">current node</a> is not an element with
5847: the same tag name as that of the token, then this is a
5848: <a href="#parse-error">parse error</a>.</p></li>
5849:
5850: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5851: until an element whose tag name is one of "h1", "h2", "h3", "h4",
5852: "h5", or "h6" has been popped from the stack.</p></li>
5853:
5854: </ol></dd>
5855:
1.953 mike 5856: <!-- see also applet/marquee/object lower down -->
5857:
1.1 mike 5858: <dt>An end tag whose tag name is "sarcasm"</dt>
5859: <dd>
5860: <p>Take a deep breath, then act as described in the "any other end
5861: tag" entry below.</p>
5862: </dd>
5863:
5864: <!-- ADOPTION AGENCY ELEMENTS
5865: Mozilla-only: bdo blink del ins sub sup q
5866: Safari-only: code dfn kbd nobr samp var wbr
5867: Both: a b big em font i s small strike strong tt u -->
5868:
5869: <dt>A start tag whose tag name is "a"</dt>
5870: <dd>
5871:
5872: <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
5873: contains an element whose tag name is "a" between the end of
5874: the list and the last marker on the list (or the start of the
5875: list if there is no marker on the list), then this is a
5876: <a href="#parse-error">parse error</a>; act as if an end tag with the tag
5877: name "a" had been seen, then remove that element from the
5878: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
5879: <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
5880: already remove it (it might not have if the element is not
5881: <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
5882: scope</a>).</p>
5883:
5884: <p class="example">In the non-conforming stream
5885: <code><a href="a">a<table><a href="b">b</table>x</code>,
1.876 mike 5886: the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing the
5887: second one, and the "x" character would be inside a link to "b",
5888: not to "a". This is despite the fact that the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code>
5889: element is not in table scope (meaning that a regular
5890: <code></a></code> end tag at the start of the table wouldn't
5891: close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element). The result is that the
5892: two <code><a href="text-level-semantics.html#the-a-element">a</a></code> elements are indirectly nested inside each
5893: other — non-conforming markup will often result in
5894: non-conforming DOMs when parsed.</p>
1.1 mike 5895:
5896: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5897: any.</p>
5898:
5899: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5900: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5901: elements</a>.</p>
5902:
5903: </dd>
5904:
5905: <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
5906: "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
5907: <dd>
5908:
5909: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5910: any.</p>
5911:
5912: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5913: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5914: elements</a>.</p>
5915:
5916: </dd>
5917:
5918: <dt>A start tag whose tag name is "nobr"</dt>
5919: <dd>
5920:
5921: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5922: any.</p>
5923:
5924: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
5925: element in scope">has a <code>nobr</code> element in scope</a>,
5926: then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
5927: the tag name "nobr" had been seen, then once again
5928: <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
5929: any.</p>
5930:
5931: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5932: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5933: elements</a>.</p>
5934:
5935: </dd>
5936:
5937: <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
5938: "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
5939: "strike", "strong", "tt", "u"</dt>
5940: <dd>
5941:
1.854 mike 5942: <p>Run these steps:</p>
1.1 mike 5943:
5944: <ol><li>
5945:
5946: <p>Let the <var title="">formatting element</var> be the
5947: last element in the <a href="#list-of-active-formatting-elements">list of active formatting
5948: elements</a> that:</p>
5949:
5950: <ul><li>is between the end of the list and the last scope
5951: marker in the list, if any, or the start of the list
5952: otherwise, and</li>
5953:
5954: <li>has the same tag name as the token.</li>
5955:
5956: </ul><p>If there is no such node, or, if that node is also in the
5957: <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
5958: <a href="#parse-error">parse error</a>; ignore the token, and abort these
5959: steps.</p>
5960:
5961: <p>Otherwise, if there is such a node, but that node is not
5962: in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
5963: <a href="#parse-error">parse error</a>; remove the element from the list,
5964: and abort these steps.</p>
5965:
5966: <p>Otherwise, there is a <var title="">formatting
5967: element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
5968: open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
5969: element in scope">in scope</a>. If the element is not the
5970: <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
5971: error</a>. In any case, proceed with the algorithm as
5972: written in the following steps.</p>
5973:
5974: </li>
5975:
5976: <li><p>Let the <var title="">furthest block</var> be the
5977: topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
5978: is lower in the stack than the <var title="">formatting
5979: element</var>, and is not an element in the
5980: <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
5981: categories. There might not be one.</p></li>
5982:
5983: <li><p>If there is no <var title="">furthest block</var>,
5984: then the UA must skip the subsequent steps and instead just
5985: pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
5986: elements</a>, from the <a href="#current-node">current node</a> up to and
5987: including the <var title="">formatting element</var>, and
5988: remove the <var title="">formatting element</var> from the
5989: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
5990:
5991: <li><p>Let the <var title="">common ancestor</var> be the element
5992: immediately above the <var title="">formatting element</var> in the
5993: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
5994:
5995: <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
5996: formatting elements</a> relative to the elements on either
5997: side of it in the list.</p></li>
5998:
5999: <li>
6000:
6001: <p>Let <var title="">node</var> and <var title="">last node</var> be the
6002: <var title="">furthest block</var>. Follow these steps:</p>
6003:
6004: <ol><li>Let <var title="">node</var> be the element immediately
6005: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436 mike 6006: elements</a>, or if <var title="">node</var> is no longer in
6007: the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
6008: removed by the next step), the element that was immediately
6009: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
6010: elements</a> before <var title="">node</var> was
6011: removed.</li>
1.1 mike 6012:
6013: <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
6014: active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
6015: elements</a> and then go back to step 1.</li>
6016:
6017: <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
6018: in the overall algorithm.</li>
6019:
6020: <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
6021: bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
6022: elements</a>.</li>
6023:
6024: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
6025: element <var title="">node</var> was created, replace the entry
6026: for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
6027: formatting elements</a> with an entry for the new element,
6028: replace the entry for <var title="">node</var> in the
6029: <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
6030: element, and let <var title="">node</var> be the new
6031: element.</li>
6032:
6033: <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
6034: parent node if any.</li>
6035:
6036: <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
6037:
6038: <li>Return to step 1 of this inner set of steps.</li>
6039:
6040: </ol></li>
6041:
6042: <li>
6043:
6044: <p>If the <var title="">common ancestor</var> node is a
6045: <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>,
6046: <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,
6047: <a href="#foster-parent">foster parent</a> whatever <var title="">last
6048: node</var> ended up being in the previous step, first removing
6049: it from its previous parent node if any.</p>
6050:
6051: <p>Otherwise, append whatever <var title="">last node</var>
6052: ended up being in the previous step to the <var title="">common
6053: ancestor</var> node, first removing it from its previous parent
6054: node if any.</p>
6055:
6056: </li>
6057:
6058: <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
6059: <var title="">formatting element</var> was created.</p></li>
6060:
6061: <li><p>Take all of the child nodes of the <var title="">furthest
6062: block</var> and append them to the element created in the last
6063: step.</p></li>
6064:
6065: <li><p>Append that new element to the <var title="">furthest
6066: block</var>.</p></li>
6067:
6068: <li><p>Remove the <var title="">formatting element</var> from the
6069: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
6070: new element into the <a href="#list-of-active-formatting-elements">list of active formatting
6071: elements</a> at the position of the aforementioned
6072: bookmark.</p></li>
6073:
6074: <li><p>Remove the <var title="">formatting element</var> from the
6075: <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
6076: into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
6077: the position of the <var title="">furthest block</var> in that
6078: stack.</p></li>
6079:
6080: <li><p>Jump back to step 1 in this series of steps.</p></li>
6081:
1.334 mike 6082: </ol><p class="note">Because of the way this algorithm causes elements
1.304 mike 6083: to change parents, it has been dubbed the "adoption agency
6084: algorithm" (in contrast with other possible algorithms for dealing
6085: with misnested content, which included the "incest algorithm", the
1.1 mike 6086: "secret affair algorithm", and the "Heisenberg algorithm").</p>
6087:
6088: </dd>
6089:
6090: <dt>A start tag token whose tag name is one of: "applet",
6091: "marquee", "object"</dt>
6092: <dd>
6093:
6094: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6095: any.</p>
6096:
6097: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6098:
6099: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6100: formatting elements</a>.</p>
6101:
6102: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6103:
6104: </dd>
6105:
1.953 mike 6106: <dt>An end tag token whose tag name is one of: "applet",
1.1 mike 6107: "marquee", "object"</dt>
6108: <dd>
6109:
6110: <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>
6111: with the same tag name as that of the token, then this is a
6112: <a href="#parse-error">parse error</a>; ignore the token.</p>
6113:
6114: <p>Otherwise, run these steps:</p>
6115:
6116: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6117:
6118: <li><p>If the <a href="#current-node">current node</a> is not an element with
6119: the same tag name as that of the token, then this is a
6120: <a href="#parse-error">parse error</a>.</p></li>
6121:
6122: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
6123: until an element with the same tag name as the token has been
6124: popped from the stack.</p></li>
6125:
6126: <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
6127: last marker</a>.</li>
6128:
6129: </ol></dd>
6130:
6131: <dt>A start tag whose tag name is "table"</dt>
6132: <dd>
6133:
1.810 mike 6134: <p>If the <code><a href="infrastructure.html#document">Document</a></code> is <em>not</em> set to
1.1 mike 6135: <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
6136: elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
6137: <code>p</code> element in scope</a>, then act as if an end tag
6138: with the tag name "p" had been seen.</p> <!-- i hate myself (this
6139: quirk was basically caused by acid2; if i'd realised we could
6140: change the specs when i wrote acid2, we could have avoided having
6141: any parsing-mode quirks) -Hixie -->
6142:
6143: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6144:
6145: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6146:
6147: <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>
6148:
6149: </dd>
6150:
6151: <dt>A start tag whose tag name is one of: "area", "basefont",
1.589 mike 6152: "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1 mike 6153: <dd>
6154:
6155: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6156: any.</p>
6157:
6158: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6159: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6160: elements</a>.</p>
6161:
6162: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6163: token's <i>self-closing flag</i></a>, if it is set.</p>
6164:
6165: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589 mike 6166: shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1 mike 6167:
6168: </dd>
6169:
6170: <dt>A start tag whose tag name is one of: "param", "source"</dt>
6171: <dd>
6172:
6173: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6174: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6175: elements</a>.</p>
6176:
6177: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6178: token's <i>self-closing flag</i></a>, if it is set.</p>
6179:
6180: </dd>
6181:
6182: <dt>A start tag whose tag name is "hr"</dt>
6183: <dd>
6184:
6185: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6186: an element in scope">has a <code>p</code> element in
6187: scope</a>, then act as if an end tag with the tag name
6188: "p" had been seen.</p>
6189:
6190: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6191: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6192: elements</a>.</p>
6193:
6194: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6195: token's <i>self-closing flag</i></a>, if it is set.</p>
6196:
6197: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6198:
6199: </dd>
6200:
6201: <dt>A start tag whose tag name is "image"</dt>
6202: <dd>
6203: <p><a href="#parse-error">Parse error</a>. Change the token's tag name
6204: to "img" and reprocess it. (Don't ask.)</p> <!-- As of
6205: 2005-12, studies showed that around 0.2% of pages used the
6206: <image> element. -->
6207: </dd>
6208:
6209: <dt id="isindex">A start tag whose tag name is "isindex"</dt>
6210: <dd>
6211:
6212: <p><a href="#parse-error">Parse error</a>.</p>
6213:
6214: <p>If the <a href="#form-element-pointer"><code title="">form</code> element
6215: pointer</a> is not null, then ignore the token.</p>
6216:
6217: <p>Otherwise:</p>
6218:
6219: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6220: token's <i>self-closing flag</i></a>, if it is set.</p> <!--
6221: purely to reduce the number of errors (we don't care if they
6222: included the /, they're not supposed to be including the tag at
6223: all! -->
6224:
6225: <p>Act as if a start tag token with the tag name "form" had been seen.</p>
6226:
6227: <p>If the token has an attribute called "action", set the
6228: <code title="attr-form-action">action</code> attribute on the
6229: resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
6230: "action" attribute of the token.</p>
6231:
6232: <p>Act as if a start tag token with the tag name "hr" had been
6233: seen.</p>
6234:
6235: <p>Act as if a start tag token with the tag name "label" had been
6236: seen.</p>
6237:
6238: <p>Act as if a stream of character tokens had been seen (see below
6239: for what they should say).</p>
6240:
6241: <p>Act as if a start tag token with the tag name "input" had been
6242: seen, with all the attributes from the "isindex" token except
6243: "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
6244: <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
6245:
6246: <p>Act as if a stream of character tokens had been seen (see
6247: below for what they should say).</p>
6248:
6249: <p>Act as if an end tag token with the tag name "label" had been
6250: seen.</p>
6251:
6252: <p>Act as if a start tag token with the tag name "hr" had been
6253: seen.</p>
6254:
6255: <p>Act as if an end tag token with the tag name "form" had been
6256: seen.</p>
6257:
6258: <p>If the token has an attribute with the name "prompt", then the
6259: first stream of characters must be the same string as given in
6260: that attribute, and the second stream of characters must be
6261: empty. Otherwise, the two streams of character tokens together
6262: should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
1.883 mike 6263: equivalent of "This is a searchable index. Enter search keywords:
6264: (input field)" in the user's preferred language.</p>
1.1 mike 6265:
6266: </dd>
6267:
6268: <dt>A start tag whose tag name is "textarea"</dt>
6269: <dd>
6270:
1.854 mike 6271: <p>Run these steps:</p>
6272:
1.1 mike 6273: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
6274: token.</p></li>
6275:
6276: <li><p>If the next token is a U+000A LINE FEED (LF) character
6277: token, then ignore that token and move on to the next
6278: one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
6279: ignored as an authoring convenience.)</p></li>
1.920 mike 6280:
1.882 mike 6281: <!-- see comment in <pre> start tag bit -->
1.1 mike 6282:
1.671 mike 6283: <li><p>Switch the tokenizer to the <a href="#rcdata-state">RCDATA
1.541 mike 6284: state</a>.</p></li>
1.1 mike 6285:
6286: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
6287: current <a href="#insertion-mode">insertion mode</a>.</p>
6288:
6289: </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
6290: ok".</p></li>
6291:
1.540 mike 6292: <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 6293:
6294: </ol></dd>
6295:
6296: <dt>A start tag whose tag name is "xmp"</dt>
6297: <dd>
6298:
1.233 mike 6299: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6300: an element in scope">has a <code>p</code> element in
6301: scope</a>, then act as if an end tag with the tag name
6302: "p" had been seen.</p>
6303:
1.1 mike 6304: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6305: any.</p>
6306:
6307: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6308:
1.91 mike 6309: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6310:
6311: </dd>
6312:
6313: <dt>A start tag whose tag name is "iframe"</dt>
6314: <dd>
6315:
6316: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6317:
1.91 mike 6318: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6319:
6320: </dd>
6321:
6322: <dt>A start tag whose tag name is "noembed"</dt>
6323: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
6324: <dd>
6325:
1.91 mike 6326: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6327:
6328: </dd>
6329:
6330: <dt>A start tag whose tag name is "select"</dt>
6331: <dd>
6332:
6333: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6334: any.</p>
6335:
6336: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6337:
6338: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6339:
6340: <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>",
6341: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6342: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
6343: row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
6344: cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
6345: "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
6346: table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
6347: to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
6348:
6349: </dd>
6350:
6351: <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
6352: <dd>
6353:
6354: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6355: element in scope">has an <code>option</code> element in
6356: scope</a>, then act as if an end tag with the tag name "option"
6357: had been seen.</p>
6358:
6359: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6360: any.</p>
6361:
6362: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6363:
6364: </dd>
6365:
6366: <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
6367: <dd>
6368:
6369: <!-- the parsing rules for ruby really don't match IE much at all,
6370: but in practice the markup used is very simple and so strict
6371: compatibility with IE isn't required. For example, as defined
6372: here we get very, very different behaviour than IE for
6373: pathological cases like:
6374:
6375: <ruby><ol><li><p>a<rt>b
6376: <ruby>a<rt>b<p>c
6377:
6378: But in practice most ruby markup falls into these cases:
6379:
6380: <ruby>a<rt>b</ruby>
6381: <ruby>a<rp>b<rt>c<rp>d</ruby>
6382: <ruby>a<rt>b</rt></ruby>
6383: <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
6384:
6385: -->
6386:
6387: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6388: element in scope">has a <code>ruby</code> element in scope</a>,
6389: then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
6390: node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
6391: <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
6392: node</a> up to the node immediately before the bottommost
6393: <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
6394: elements</a>.</p>
6395:
6396: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6397:
6398: </dd>
6399:
6400: <dt>An end tag whose tag name is "br"</dt>
6401: <dd>
6402: <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
6403: the tag name "br" had been seen. Ignore the end tag token.</p>
6404: </dd>
6405:
6406: <dt>A start tag whose tag name is "math"</dt>
6407: <dd>
6408:
6409: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6410: any.</p>
6411:
6412: <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
6413: fixes the case of MathML attributes that are not all
6414: lowercase.)</p>
6415:
6416: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6417: fixes the use of namespaced attributes, in particular XLink.)</p>
6418:
6419: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724 mike 6420: <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</p>
1.1 mike 6421:
6422: <!-- If we ever change the frameset-ok flag to an insertion mode,
6423: the following change would be implied, except we'd have to do it
6424: even in the face of a self-closed tag:
6425: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6426: -->
6427:
6428: <p>If the token has its <i>self-closing flag</i> set, pop the
6429: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6430: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6431: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6432:
6433: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6434: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6435: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6436: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6437: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6438: foreign content">in foreign content</a>".</p>
6439:
6440: </dd>
6441:
6442: <dt>A start tag whose tag name is "svg"</dt>
6443: <dd>
6444:
6445: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6446: any.</p>
6447:
6448: <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
6449: the case of SVG attributes that are not all lowercase.)</p>
6450:
6451: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6452: fixes the use of namespaced attributes, in particular XLink in
6453: SVG.)</p>
6454:
6455: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724 mike 6456: <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</p>
1.1 mike 6457:
6458: <!-- If we ever change the frameset-ok flag to an insertion mode,
6459: the following change would be implied, except we'd have to do it
6460: even in the face of a self-closed tag:
6461: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6462: -->
6463:
6464: <p>If the token has its <i>self-closing flag</i> set, pop the
6465: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6466: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6467: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6468:
6469: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6470: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6471: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6472: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6473: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6474: foreign content">in foreign content</a>".</p>
6475:
6476: </dd>
6477:
6478: <dt>A start <!--or end--> tag whose tag name is one of: "caption",
6479: "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
6480: "thead", "tr"</dt>
6481: <!--<dt>An end tag whose tag name is one of: "area", "base",
6482: "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
6483: "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589 mike 6484: "noframes", "param", "script", "select", "source", "style",
6485: "table", "textarea", "title", "wbr"</dt>-->
1.1 mike 6486: <!--<dt>An end tag whose tag name is "noscript", if the
6487: <span>scripting flag</span> is enabled</dt>-->
6488: <dd>
6489: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6490: <!-- end tags are commented out because since they can never end
6491: up on the stack anyway, the default end tag clause will
6492: automatically handle them. we don't want to have text in the spec
6493: that is just an optimisation, as that detracts from the spec
6494: itself -->
6495: </dd>
6496:
6497: <dt>Any other start tag</dt>
6498: <dd>
6499:
6500: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6501: any.</p>
6502:
6503: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6504:
6505: <p class="note">This element will be a <a href="#phrasing">phrasing</a>
6506: element.</p>
6507:
6508: </dd>
6509:
6510: <dt>Any other end tag</dt>
6511: <dd>
6512:
1.854 mike 6513: <p>Run these steps:</p>
1.1 mike 6514:
6515: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
6516: node</a> (the bottommost node of the stack).</p></li>
6517:
6518: <li><p>If <var title="">node</var> has the same tag name as
1.856 mike 6519: the token, then:</p>
1.1 mike 6520:
6521: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6522:
6523: <li><p>If the tag name of the end tag token does not match
6524: the tag name of the <a href="#current-node">current node</a>, this is a
6525: <a href="#parse-error">parse error</a>.</p></li>
6526:
6527: <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
6528: to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
6529:
6530: </ol></li>
6531:
6532: <li><p>Otherwise, if <var title="">node</var> is in neither the
6533: <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
6534: category, then this is a <a href="#parse-error">parse error</a>; ignore the
6535: token, and abort these steps.</p></li>
6536:
6537: <li><p>Set <var title="">node</var> to the previous entry in the
6538: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
6539:
6540: <li><p>Return to step 2.</p></li>
6541:
6542: </ol></dd>
6543:
1.895 mike 6544: </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 6545:
6546: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540 mike 6547: mode: text">text</a>", tokens must be handled as follows:</p>
1.1 mike 6548:
6549: <dl class="switch"><dt>A character token</dt>
6550: <dd>
6551:
6552: <p><a href="#insert-a-character" title="insert a character">Insert the token's
6553: character</a> into the <a href="#current-node">current node</a>.</p>
6554:
6555: </dd>
6556:
6557: <dt>An end-of-file token</dt>
6558: <dd>
6559:
6560: <!-- can't be the fragment case -->
6561: <p><a href="#parse-error">Parse error</a>.</p>
6562:
6563: <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484 mike 6564: element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
6565: started"</a>.</p>
1.1 mike 6566:
6567: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6568: elements</a>.</p>
6569:
6570: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6571: insertion mode</a> and reprocess the current token.</p>
6572:
6573: </dd>
6574:
1.878 mike 6575: <dt id="scriptEndTag">An end tag whose tag name is "script"</dt>
1.1 mike 6576: <dd>
6577:
6578: <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
6579: (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
6580:
6581: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6582: elements</a>.</p>
6583:
6584: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6585: insertion mode</a>.</p>
6586:
6587: <p>Let the <var title="">old insertion point</var> have the
6588: same value as the current <a href="#insertion-point">insertion point</a>. Let
6589: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
6590: input character</a>.</p>
6591:
6592: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
6593: one.</p>
6594:
6595: <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 6596: which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1 mike 6597: to be inserted into the tokenizer</a>, and might cause the
6598: tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
6599:
6600: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
6601: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
6602: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6603:
6604: <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
6605: <a href="#insertion-point">insertion point</a> to its previous value. This value
6606: might be the "undefined" value.)</p>
6607:
6608: <p id="scriptTagParserResumes">At this stage, if there is a
1.484 mike 6609: <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1 mike 6610:
6611: <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
6612:
6613: <dd>
6614:
6615: <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
6616: processing of any nested invocations of the tokenizer, yielding
6617: control back to the caller. (Tokenization will resume when the
6618: caller returns to the "outer" tree construction stage.)</p>
6619:
6620: <p class="note">The tree construction stage of this particular
6621: parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159 mike 6622: 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 6623:
6624: </dd>
6625:
6626:
6627: <dt>Otherwise:</dt>
6628:
6629: <dd>
6630:
1.854 mike 6631: <p>Run these steps:</p>
1.1 mike 6632:
1.484 mike 6633: <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
6634: parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
6635: parsing-blocking script</a>.</p></li>
6636:
6637: <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
6638: for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794 mike 6639: 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 6640:
1.794 mike 6641: <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 6642: scripts</a> and <var title="">the script</var>'s
6643: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
6644:
6645: <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
6646: for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794 mike 6647: <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 6648: run.</p></li>
1.1 mike 6649:
6650: <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
6651: <a href="#next-input-character">next input character</a>.</p></li>
6652:
6653: <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
6654: by one (it should be zero before this step, so this sets it to
6655: one).</p></li>
6656:
1.484 mike 6657: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
6658: <var title="">the script</var>.</p></li>
1.1 mike 6659:
6660: <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
6661: by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
6662: zero (which it always should be at this point), then set the
6663: <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6664:
6665: </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
6666: again.</p></li>
6667:
1.484 mike 6668: <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1 mike 6669: script</a>, then repeat these steps from step 1.</p></li>
6670:
6671: </ol></dd>
6672:
6673: </dl></dd>
6674:
6675: <dt>Any other end tag</dt>
6676: <dd>
6677:
6678: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6679: elements</a>.</p>
6680:
6681: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6682: insertion mode</a>.</p>
6683:
6684: </dd>
6685:
1.895 mike 6686: </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 6687:
6688: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
6689: mode: in table">in table</a>", tokens must be handled as follows:</p>
6690:
6691: <dl class="switch"><dt>A character token</dt>
6692: <dd>
6693:
6694: <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
6695: be an empty list of tokens.</p>
6696:
6697: <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
6698: <a href="#insertion-mode">insertion mode</a>.</p>
6699:
6700: <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
6701: reprocess the token.</p>
6702:
6703: </dd>
6704:
6705: <dt>A comment token</dt>
6706: <dd>
1.882 mike 6707: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 6708: node</a> with the <code title="">data</code> attribute set to
6709: the data given in the comment token.</p>
6710: </dd>
6711:
6712: <dt>A DOCTYPE token</dt>
6713: <dd>
6714: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6715: </dd>
6716:
6717: <dt>A start tag whose tag name is "caption"</dt>
6718: <dd>
6719:
6720: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6721: below.)</p>
6722:
6723: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6724: formatting elements</a>.</p>
6725:
6726: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6727: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
6728:
6729: </dd>
6730:
6731: <dt>A start tag whose tag name is "colgroup"</dt>
6732: <dd>
6733:
6734: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6735: below.)</p>
6736:
6737: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6738: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
6739: group</a>".</p>
6740:
6741: </dd>
6742:
6743: <dt>A start tag whose tag name is "col"</dt>
6744: <dd>
6745: <p>Act as if a start tag token with the tag name "colgroup"
6746: had been seen, then reprocess the current token.</p>
6747: </dd>
6748:
6749: <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
6750: <dd>
6751:
6752: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6753: below.)</p>
6754:
6755: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6756: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6757: body</a>".</p>
6758:
6759: </dd>
6760:
6761: <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
6762: <dd>
6763: <p>Act as if a start tag token with the tag name "tbody" had
6764: been seen, then reprocess the current token.</p>
6765: </dd>
6766:
6767: <dt>A start tag whose tag name is "table"</dt>
6768: <dd>
6769:
6770: <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
6771: the tag name "table" had been seen, then, if that token wasn't
6772: ignored, reprocess the current token.</p>
6773:
6774: <p class="note">The fake end tag token here can only be
6775: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6776:
6777: </dd>
6778:
6779: <dt>An end tag whose tag name is "table"</dt>
6780: <dd>
6781:
6782: <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
6783: scope</a> with the same tag name as the token, this is a
6784: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6785: case</a>)</p>
6786:
6787: <p>Otherwise:</p>
6788:
6789: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
6790: element has been popped from the stack.</p>
6791:
6792: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
6793:
6794: </dd>
6795:
6796: <dt>An end tag whose tag name is one of: "body", "caption",
6797: "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
6798: "thead", "tr"</dt>
6799: <dd>
6800: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6801: </dd>
6802:
6803: <dt>A start tag whose tag name is one of: "style", "script"</dt>
6804: <dd>
6805:
6806: <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
6807: mode</a>.</p>
6808:
6809: </dd>
6810:
6811: <dt>A start tag whose tag name is "input"</dt>
6812: <dd>
6813:
6814: <p>If the token does not have an attribute with the name "type",
6815: or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
6816: case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
6817: else" entry below.</p>
6818:
6819: <p>Otherwise:</p>
6820:
6821: <p><a href="#parse-error">Parse error</a>.</p>
6822:
6823: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6824:
6825: <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
6826: open elements</a>.</p>
6827:
6828: </dd>
6829:
1.603 mike 6830: <dt>A start tag whose tag name is "form"</dt>
6831: <dd>
6832:
6833: <p><a href="#parse-error">Parse error</a>.</p>
6834:
1.717 mike 6835: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
6836: pointer</a> is not null, ignore the token.</p>
6837:
6838: <p>Otherwise:</p>
6839:
1.603 mike 6840: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6841:
1.637 mike 6842: <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 6843: open elements</a>.</p>
6844:
6845: </dd>
6846:
1.721 mike 6847: <!-- "form" end tag falls through to in-body, which does the right thing -->
1.717 mike 6848:
1.1 mike 6849: <dt>An end-of-file token</dt>
6850: <dd>
6851:
6852: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 6853: <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 6854: error</a>.</p>
6855:
6856: <p class="note">It can only be the <a href="#current-node">current node</a> in
6857: the <a href="#fragment-case">fragment case</a>.</p>
6858:
6859: <p><a href="#stop-parsing">Stop parsing</a>.</p>
6860:
6861: </dd>
6862:
6863: <dt>Anything else</dt>
6864: <dd>
6865:
6866: <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
6867: rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
6868: body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
6869: <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
6870: <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
6871: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
6872: into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
6873:
6874: </dd>
6875:
6876: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
6877: back to a table context</dfn>, it means that the UA must, while
6878: 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 6879: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 6880: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
6881:
6882: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 6883: <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 6884: case</a>.</p>
6885:
6886:
6887:
1.895 mike 6888: <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 6889:
6890: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
6891: mode: in table text">in table text</a>", tokens must be handled
6892: as follows:</p>
6893:
6894: <dl class="switch"><dt>A character token</dt>
6895: <dd>
6896:
6897: <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
6898: tokens</a></var> list.</p>
6899:
6900: </dd>
6901:
6902:
6903: <dt>Anything else</dt>
6904: <dd>
6905:
6906: <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
6907: tokens</a></var> list are character tokens that are not one of U+0009
6908: CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
1.882 mike 6909: (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE, then
1.1 mike 6910: reprocess those character tokens using the rules given in the
6911: "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
6912: table">in table</a>" insertion mode.</p>
6913:
6914: <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
6915: characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
6916: tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
6917:
6918: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6919: insertion mode</a> and reprocess the token.</p>
6920:
6921: </dd>
6922:
1.895 mike 6923: </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 6924:
6925: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
6926: mode: in caption">in caption</a>", tokens must be handled as follows:</p>
6927:
6928: <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
6929: <dd>
6930:
6931: <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
6932: scope</a> with the same tag name as the token, this is a
6933: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6934: case</a>)</p>
6935:
6936: <p>Otherwise:</p>
6937:
6938: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
6939:
6940: <p>Now, if the <a href="#current-node">current node</a> is not a
6941: <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
6942: error</a>.</p>
6943:
6944: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
6945: element has been popped from the stack.</p>
6946:
6947: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
6948: the last marker</a>.</p>
6949:
6950: <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>
6951:
6952: </dd>
6953:
6954: <dt>A start tag whose tag name is one of: "caption", "col",
6955: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
6956: <dt>An end tag whose tag name is "table"</dt>
6957: <dd>
6958:
6959: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
6960: name "caption" had been seen, then, if that token wasn't
6961: ignored, reprocess the current token.</p>
6962:
6963: <p class="note">The fake end tag token here can only be
6964: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6965:
6966: </dd>
6967:
6968: <dt>An end tag whose tag name is one of: "body", "col",
6969: "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
6970: "tr"</dt>
6971: <dd>
6972: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6973: </dd>
6974:
6975: <dt>Anything else</dt>
6976: <dd>
6977: <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
6978: mode</a>.</p>
6979: </dd>
6980:
1.895 mike 6981: </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 6982:
6983: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
6984: mode: in column group">in column group</a>", tokens must be handled as follows:</p>
6985:
6986: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
6987: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 6988: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 6989: <dd>
6990: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
6991: the <a href="#current-node">current node</a>.</p>
6992: </dd>
6993:
6994: <dt>A comment token</dt>
6995: <dd>
1.882 mike 6996: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 6997: node</a> with the <code title="">data</code> attribute set to
6998: the data given in the comment token.</p>
6999: </dd>
7000:
7001: <dt>A DOCTYPE token</dt>
7002: <dd>
7003: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7004: </dd>
7005:
7006: <dt>A start tag whose tag name is "html"</dt>
7007: <dd>
7008: <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
7009: mode</a>.</p>
7010: </dd>
7011:
7012: <dt>A start tag whose tag name is "col"</dt>
7013: <dd>
7014:
7015: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
7016: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7017: elements</a>.</p>
7018:
7019: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
7020: token's <i>self-closing flag</i></a>, if it is set.</p>
7021:
7022: </dd>
7023:
7024: <dt>An end tag whose tag name is "colgroup"</dt>
7025: <dd>
7026:
7027: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 7028: <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 7029: error</a>; ignore the token. (<a href="#fragment-case">fragment
7030: case</a>)</p>
7031:
7032: <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
7033: 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
7034: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
7035: "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
7036:
7037: </dd>
7038:
7039: <dt>An end tag whose tag name is "col"</dt>
7040: <dd>
7041: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7042: </dd>
7043:
7044: <dt>An end-of-file token</dt>
7045: <dd>
7046:
1.159 mike 7047: <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 7048: element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
7049: case</a>)</p>
7050:
7051: <p>Otherwise, act as described in the "anything else" entry
7052: below.</p>
7053:
7054: </dd>
7055:
7056: <dt>Anything else</dt>
7057: <dd>
7058:
7059: <p>Act as if an end tag with the tag name "colgroup" had been
7060: seen, and then, if that token wasn't ignored, reprocess the
7061: current token.</p>
7062:
7063: <p class="note">The fake end tag token here can only be
7064: ignored in the <a href="#fragment-case">fragment case</a>.</p>
7065:
7066: </dd>
7067:
1.895 mike 7068: </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 7069:
7070: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
7071: mode: in table body">in table body</a>", tokens must be handled as follows:</p>
7072:
7073: <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
7074: <dd>
7075:
7076: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7077: context</a>. (See below.)</p>
7078:
7079: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
7080: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
7081: in row">in row</a>".</p>
7082:
7083: </dd>
7084:
7085: <dt>A start tag whose tag name is one of: "th", "td"</dt>
7086: <dd>
7087: <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
7088: the tag name "tr" had been seen, then reprocess the current
7089: token.</p>
7090: </dd>
7091:
7092: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
7093: "thead"</dt>
7094: <dd>
7095:
7096: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
7097: scope</a> with the same tag name as the token, this is a
7098: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7099:
7100: <p>Otherwise:</p>
7101:
7102: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7103: context</a>. (See below.)</p>
7104:
7105: <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
7106: open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7107: to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
7108:
7109: </dd>
7110:
7111: <dt>A start tag whose tag name is one of: "caption", "col",
7112: "colgroup", "tbody", "tfoot", "thead"</dt>
7113: <dt>An end tag whose tag name is "table"</dt>
7114: <dd>
7115:
7116: <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
7117: <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
7118: element in table scope</a>, this is a <a href="#parse-error">parse
7119: error</a>. Ignore the token. (<a href="#fragment-case">fragment
7120: case</a>)</p>
7121:
7122: <p>Otherwise:</p>
7123:
7124: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7125: context</a>. (See below.)</p>
7126:
7127: <p>Act as if an end tag with the same tag name as the
7128: <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
7129: been seen, then reprocess the current token.</p>
7130:
7131: </dd>
7132:
7133: <dt>An end tag whose tag name is one of: "body", "caption",
7134: "col", "colgroup", "html", "td", "th", "tr"</dt>
7135: <dd>
7136: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7137: </dd>
7138:
7139: <dt>Anything else</dt>
7140: <dd>
7141: <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
7142: mode</a>.</p>
7143: </dd>
7144:
7145: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
7146: back to a table body context</dfn>, it means that the UA must,
7147: 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 7148: <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 7149: element, pop elements from the <a href="#stack-of-open-elements">stack of open
7150: elements</a>.</p>
7151:
7152: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 7153: <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 7154: case</a>.</p>
7155:
7156:
1.895 mike 7157: <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 7158:
7159: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
7160: mode: in row">in row</a>", tokens must be handled as follows:</p>
7161:
7162: <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
7163: <dd>
7164:
7165: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7166: context</a>. (See below.)</p>
7167:
7168: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
7169: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
7170: in cell">in cell</a>".</p>
7171:
7172: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
7173: formatting elements</a>.</p>
7174:
7175: </dd>
7176:
7177: <dt>An end tag whose tag name is "tr"</dt>
7178: <dd>
7179:
7180: <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
7181: scope</a> with the same tag name as the token, this is a
7182: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7183: case</a>)</p>
7184:
7185: <p>Otherwise:</p>
7186:
7187: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7188: context</a>. (See below.)</p>
7189:
7190: <p>Pop the <a href="#current-node">current node</a> (which will be a
7191: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
7192: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
7193: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
7194: body</a>".</p>
7195:
7196: </dd>
7197:
7198: <dt>A start tag whose tag name is one of: "caption", "col",
7199: "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
7200: <dt>An end tag whose tag name is "table"</dt>
7201: <dd>
7202:
7203: <p>Act as if an end tag with the tag name "tr" had been seen,
7204: then, if that token wasn't ignored, reprocess the current
7205: token.</p>
7206:
7207: <p class="note">The fake end tag token here can only be
7208: ignored in the <a href="#fragment-case">fragment case</a>.</p>
7209:
7210: </dd>
7211:
7212: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
7213: "thead"</dt>
7214: <dd>
7215:
7216: <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
7217: scope</a> with the same tag name as the token, this is a
7218: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7219:
7220: <p>Otherwise, act as if an end tag with the tag name "tr" had
7221: been seen, then reprocess the current token.</p>
7222:
7223: </dd>
7224:
7225: <dt>An end tag whose tag name is one of: "body", "caption",
7226: "col", "colgroup", "html", "td", "th"</dt>
7227: <dd>
7228: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7229: </dd>
7230:
7231: <dt>Anything else</dt>
7232: <dd>
7233: <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
7234: mode</a>.</p>
7235: </dd>
7236:
7237: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
7238: back to a table row context</dfn>, it means that the UA must,
7239: 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 7240: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 7241: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7242:
7243: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 7244: <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 7245: case</a>.</p>
7246:
7247:
1.895 mike 7248: <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 7249:
7250: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
7251: mode: in cell">in cell</a>", tokens must be handled as follows:</p>
7252:
7253: <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
7254: <dd>
7255:
7256: <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
7257: scope</a> with the same tag name as that of the token, then
7258: this is a <a href="#parse-error">parse error</a> and the token must be
7259: ignored.</p>
7260:
7261: <p>Otherwise:</p>
7262:
7263: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
7264:
7265: <p>Now, if the <a href="#current-node">current node</a> is not an element
7266: with the same tag name as the token, then this is a
7267: <a href="#parse-error">parse error</a>.</p>
7268:
1.856 mike 7269: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> stack
7270: until an element with the same tag name as the token has been
7271: popped from the stack.</p>
1.1 mike 7272:
7273: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
7274: the last marker</a>.</p>
7275:
7276: <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
7277: <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
7278: this point.)</p>
7279:
7280: </dd>
7281:
7282: <dt>A start tag whose tag name is one of: "caption", "col",
7283: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
7284: <dd>
7285:
7286: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
7287: <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
7288: a <code>td</code> or <code>th</code> element in table
7289: scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
7290: the token. (<a href="#fragment-case">fragment case</a>)</p>
7291:
7292: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7293: reprocess the current token.</p>
7294:
7295: </dd>
7296:
7297: <dt>An end tag whose tag name is one of: "body", "caption",
7298: "col", "colgroup", "html"</dt>
7299: <dd>
7300: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7301: </dd>
7302:
7303: <dt>An end tag whose tag name is one of: "table", "tbody",
7304: "tfoot", "thead", "tr"</dt>
7305: <dd>
7306:
7307: <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
7308: scope</a> with the same tag name as that of the token
7309: (which can only happen for "tbody", "tfoot" and "thead", or,
7310: in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
7311: error</a> and the token must be ignored.</p>
7312:
7313: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7314: reprocess the current token.</p>
7315:
7316: </dd>
7317:
7318: <dt>Anything else</dt>
7319: <dd>
7320: <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
7321: mode</a>.</p>
7322: </dd>
7323:
7324: </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
7325: mean to run the following algorithm:</p>
7326:
7327: <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>
7328: element in table scope</a>, then act as if an end tag token
7329: with the tag name "td" had been seen.</p></li>
7330:
7331: <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
7332: <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
7333: <code>th</code> element in table scope</a>; act as if an end
7334: tag token with the tag name "th" had been seen.</p></li>
7335:
7336: </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
7337: 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
7338: the same time, nor can it have neither when the <a href="#insertion-mode">insertion
7339: mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
7340: cell</a>".</p>
7341:
7342:
1.895 mike 7343: <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 7344:
7345: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
7346: mode: in select">in select</a>", tokens must be handled as follows:</p>
7347:
7348: <dl class="switch"><dt>A character token</dt>
7349: <dd>
7350: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7351: character</a> into the <a href="#current-node">current node</a>.</p>
7352: </dd>
7353:
7354: <dt>A comment token</dt>
7355: <dd>
1.882 mike 7356: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7357: node</a> with the <code title="">data</code> attribute set to
7358: the data given in the comment token.</p>
7359: </dd>
7360:
7361: <dt>A DOCTYPE token</dt>
7362: <dd>
7363: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7364: </dd>
7365:
7366: <dt>A start tag whose tag name is "html"</dt>
7367: <dd>
7368: <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
7369: mode</a>.</p>
7370: </dd>
7371:
7372: <dt>A start tag whose tag name is "option"</dt>
7373: <dd>
7374:
7375: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7376: element, act as if an end tag with the tag name "option" had
7377: been seen.</p>
7378:
7379: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7380:
7381: </dd>
7382:
7383: <dt>A start tag whose tag name is "optgroup"</dt>
7384: <dd>
7385:
7386: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7387: element, act as if an end tag with the tag name "option" had
7388: been seen.</p>
7389:
7390: <p>If the <a href="#current-node">current node</a> is an
7391: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
7392: tag name "optgroup" had been seen.</p>
7393:
7394: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7395:
7396: </dd>
7397:
7398: <dt>An end tag whose tag name is "optgroup"</dt>
7399: <dd>
7400:
7401: <p>First, if the <a href="#current-node">current node</a> is an
7402: <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
7403: it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
7404: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
7405: the tag name "option" had been seen.</p>
7406:
7407: <p>If the <a href="#current-node">current node</a> is an
7408: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
7409: <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
7410: <a href="#parse-error">parse error</a>; ignore the token.</p>
7411:
7412: </dd>
7413:
7414: <dt>An end tag whose tag name is "option"</dt>
7415: <dd>
7416:
7417: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7418: element, then pop that node from the <a href="#stack-of-open-elements">stack of open
7419: elements</a>. Otherwise, this is a <a href="#parse-error">parse
7420: error</a>; ignore the token.</p>
7421:
7422: </dd>
7423:
7424: <dt>An end tag whose tag name is "select"</dt>
7425: <dd>
7426:
7427: <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
7428: scope</a> with the same tag name as the token, this is a
7429: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7430: case</a>)</p>
7431:
7432: <p>Otherwise:</p>
7433:
7434: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
7435: until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
7436: stack.</p>
7437:
7438: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
7439:
7440: </dd>
7441:
7442: <dt>A start tag whose tag name is "select"</dt>
7443: <dd>
7444:
7445: <p><a href="#parse-error">Parse error</a>. Act as if the token had been
7446: an end tag with the tag name "select" instead.</p>
7447:
7448: </dd>
7449:
7450: <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
7451: <dd>
1.73 mike 7452:
7453: <p><a href="#parse-error">Parse error</a>.</p>
7454:
1.124 mike 7455: <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>
7456: element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
7457: case</a>)</p>
1.73 mike 7458:
7459: <p>Otherwise, act as if an end tag with the tag name "select" had
7460: been seen, and reprocess the token.</p>
7461:
1.1 mike 7462: </dd>
7463:
7464: <dt>A start tag token whose tag name is "script"</dt>
7465: <dd>
7466: <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
7467: mode</a>.</p>
7468: </dd>
7469:
7470: <dt>An end-of-file token</dt>
7471: <dd>
7472:
7473: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7474: <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 7475: error</a>.</p>
7476:
7477: <p class="note">It can only be the <a href="#current-node">current node</a> in
7478: the <a href="#fragment-case">fragment case</a>.</p>
7479:
7480: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7481:
7482: </dd>
7483:
7484: <dt>Anything else</dt>
7485: <dd>
7486: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7487: </dd>
7488:
1.895 mike 7489: </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 7490:
7491: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
7492: mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
7493:
7494: <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
7495: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7496: <dd>
7497: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
7498: name "select" had been seen, and reprocess the token.</p>
7499: </dd>
7500:
7501: <dt>An end tag whose tag name is one of: "caption", "table",
7502: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7503: <dd>
7504:
7505: <p><a href="#parse-error">Parse error</a>.</p>
7506:
7507: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
7508: element in table scope</a> with the same tag name as that
7509: of the token, then act as if an end tag with the tag name
7510: "select" had been seen, and reprocess the token. Otherwise,
7511: ignore the token.</p>
7512:
7513: </dd>
7514:
7515: <dt>Anything else</dt>
7516: <dd>
7517: <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
7518: mode</a>.</p>
7519: </dd>
7520:
1.895 mike 7521: </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 7522:
7523: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
7524: mode: in foreign content">in foreign content</a>", tokens must be
7525: handled as follows:</p>
7526:
7527: <dl class="switch"><dt>A character token</dt>
7528: <dd>
7529:
7530: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7531: character</a> into the <a href="#current-node">current node</a>.</p>
7532:
7533: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
1.882 mike 7534: LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN
7535: (CR), or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
1.1 mike 7536: flag</a> to "not ok".</p>
7537:
7538: </dd>
7539:
7540: <dt>A comment token</dt>
7541: <dd>
1.882 mike 7542: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7543: node</a> with the <code title="">data</code> attribute set to
7544: the data given in the comment token.</p>
7545: </dd>
7546:
7547: <dt>A DOCTYPE token</dt>
7548: <dd>
7549: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7550: </dd>
7551:
1.878 mike 7552: <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 7553: <dd>
7554:
7555: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7556: elements</a>.</p>
7557:
7558: <p>Let the <var title="">old insertion point</var> have the
7559: same value as the current <a href="#insertion-point">insertion point</a>. Let
7560: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
7561: input character</a>.</p>
7562:
7563: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
7564: one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
7565:
7566: <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
7567: the <code title="">script</code> element</a> according to the SVG
1.187 mike 7568: rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1 mike 7569:
1.159 mike 7570: <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 7571: tokenizer</a>, the parser will not be executed reentrantly,
7572: since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
7573:
7574: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
7575: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
7576: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
7577:
7578: <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
7579: <a href="#insertion-point">insertion point</a> to its previous value. This value
7580: might be the "undefined" value.)</p>
7581:
7582: </dd>
7583:
1.855 mike 7584: <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>
7585:
7586: <dd>
7587:
7588: <p>Run these steps:</p>
7589:
7590: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
7591: node</a> (the bottommost node of the stack).</p></li>
7592:
7593: <li><p>If <var title="">node</var> is not an element with the
7594: same tag name as the token, then this is a <a href="#parse-error">parse
7595: error</a>.</p></li>
7596:
7597: <li><p><i>Loop</i>: If <var title="">node</var> has the same tag
7598: name as the token, pop elements from the <a href="#stack-of-open-elements">stack of
7599: open elements</a> until <var title="">node</var> has been
7600: popped from the stack, and then abort these steps.</p></li>
7601:
7602: <li><p>Set <var title="">node</var> to the previous entry in the
7603: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
7604:
7605: <li>
7606:
7607: <p>If <var title="">node</var> is an element in the <a href="infrastructure.html#html-namespace-0">HTML
7608: namespace</a>, process the token <a href="#using-the-rules-for">using the rules
7609: for</a> the <a href="#secondary-insertion-mode">secondary insertion mode</a>. If, after
7610: 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
7611: content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
7612: element in scope">in scope</a> that has a namespace other
7613: than the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
7614: mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7615:
7616: </li>
7617:
7618: <li><p>Return to the step labeled <i>loop</i>.</p></li>
7619:
7620: </ol></dd>
7621:
1.724 mike 7622: <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>
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="">mo</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="">mn</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="">ms</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="">mtext</code> element in the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
7627: <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>
7628: <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>
7629: <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>
7630: <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>
7631: <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 7632: <dt>Any other end tag</dt>
1.1 mike 7633: <dd>
7634:
7635: <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
7636: <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7637:
7638: <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
7639: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336 mike 7640: content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
7641: element in scope">in scope</a> that has a namespace other than
1.724 mike 7642: the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1 mike 7643: mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7644:
7645: </dd>
7646:
7647: <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
7648: "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422 mike 7649: "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
7650: uniformly throughout the parser -->, "em", "embed", "h1", "h2",
7651: "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1 mike 7652: completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
7653: "li", "listing"<!-- so that pre and listing can be handled
7654: uniformly throughout the parser -->, "menu", "meta", "nobr",
7655: "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
7656: the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
7657: "span", "strong", "strike"<!-- so that s and strike can be handled
7658: uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305 mike 7659: "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
7660: list was determined empirically by studying over 6,000,000,000
1.422 mike 7661: pages that were specifically not XML pages -->
7662: <dt>A start tag whose tag name is "font", if the token has any
7663: attributes named "color", "face", or "size"</dt> <!-- the
7664: attributes here are required so that SVG <font> will go through as
7665: SVG but legacy <font>s won't -->
7666: <dt>An end-of-file token</dt> <dd>
1.1 mike 7667:
7668: <p><a href="#parse-error">Parse error</a>.</p>
7669:
7670: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
1.857 mike 7671: 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
7672: has been popped from the stack, and reprocess the token.</p>
1.1 mike 7673:
7674: </dd>
7675:
7676: <dt>Any other start tag</dt>
7677: <dd>
7678:
7679: <p>If the <a href="#current-node">current node</a> is an element in the
1.724 mike 7680: <a href="infrastructure.html#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
1.1 mike 7681: attributes</a> for the token. (This fixes the case of MathML
7682: attributes that are not all lowercase.)</p>
7683:
1.724 mike 7684: <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 7685: namespace</a>, and the token's tag name is one of the ones in
7686: the first column of the following table, change the tag name to
7687: the name given in the corresponding cell in the second
7688: column. (This fixes the case of SVG elements that are not all
7689: lowercase.)</p>
7690:
7691: <table><thead><tr><th> Tag name </th><th> Element name
7692: </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
7693: </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
7694: </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
7695: </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
7696: </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
7697: </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
7698: </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
7699: </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
7700: </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
7701: </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
7702: </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
7703: </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
7704: </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
7705: </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
7706: </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
7707: </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
7708: </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
7709: </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
7710: </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
7711: </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
7712: </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
7713: </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
7714: </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
7715: </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
7716: </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
7717: </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
7718: </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
7719: </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
7720: </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
7721: </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
7722: </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
7723: </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
7724: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
7725: </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
7726: </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
7727: <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
7728: </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
1.724 mike 7729: </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 7730: namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
7731: token. (This fixes the case of SVG attributes that are not all
7732: lowercase.)</p>
7733:
7734: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
7735: fixes the use of namespaced attributes, in particular XLink in
7736: SVG.)</p>
7737:
7738: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
7739: same namespace as the <a href="#current-node">current node</a>.</p>
7740:
7741: <p>If the token has its <i>self-closing flag</i> set, pop the
7742: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7743: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
7744: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
7745:
7746: </dd>
7747:
1.895 mike 7748: </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 7749:
7750: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
7751: mode: after body">after body</a>", tokens must be handled as follows:</p>
7752:
7753: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7754: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7755: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7756: <dd>
7757: <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
7758: mode</a>.</p>
7759: </dd>
7760:
7761: <dt>A comment token</dt>
7762: <dd>
1.882 mike 7763: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the first element in
1.159 mike 7764: 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 7765: element), with the <code title="">data</code> attribute set to
7766: the data given in the comment token.</p>
7767: </dd>
7768:
7769: <dt>A DOCTYPE token</dt>
7770: <dd>
7771: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7772: </dd>
7773:
7774: <dt>A start tag whose tag name is "html"</dt>
7775: <dd>
7776: <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
7777: mode</a>.</p>
7778: </dd>
7779:
7780: <dt>An end tag whose tag name is "html"</dt>
7781: <dd>
7782:
7783: <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
7784: fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
7785: error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
7786:
7787: <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
7788: body</a>".</p>
7789:
7790: </dd>
7791:
7792: <dt>An end-of-file token</dt>
7793: <dd>
7794: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7795: </dd>
7796:
7797: <dt>Anything else</dt>
7798: <dd>
7799:
7800: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
7801: mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
7802: body</a>" and reprocess the token.</p>
7803:
7804: </dd>
7805:
1.895 mike 7806: </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 7807:
7808: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
7809: mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
7810:
7811: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7812: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7813: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7814: <dd>
7815: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7816: the <a href="#current-node">current node</a>.</p>
7817: </dd>
7818:
7819: <dt>A comment token</dt>
7820: <dd>
1.882 mike 7821: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7822: node</a> with the <code title="">data</code> attribute set to
7823: the data given in the comment token.</p>
7824: </dd>
7825:
7826: <dt>A DOCTYPE token</dt>
7827: <dd>
7828: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7829: </dd>
7830:
7831: <dt>A start tag whose tag name is "html"</dt>
7832: <dd>
7833: <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
7834: mode</a>.</p>
7835: </dd>
7836:
7837: <dt>A start tag whose tag name is "frameset"</dt>
7838: <dd>
7839: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7840: </dd>
7841:
7842: <dt>An end tag whose tag name is "frameset"</dt>
7843: <dd>
7844:
7845: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 7846: <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 7847: error</a>; ignore the token. (<a href="#fragment-case">fragment
7848: case</a>)</p>
7849:
7850: <p>Otherwise, pop the <a href="#current-node">current node</a> from the
7851: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7852:
7853: <p>If the parser was <em>not</em> originally created as part
7854: of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
7855: (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5 mike 7856: node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1 mike 7857: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
7858: frameset</a>".</p>
7859:
7860: </dd>
7861:
7862: <dt>A start tag whose tag name is "frame"</dt>
7863: <dd>
7864:
7865: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
7866: Immediately pop the <a href="#current-node">current node</a> off the
7867: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7868:
7869: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
7870: token's <i>self-closing flag</i></a>, if it is set.</p>
7871:
7872: </dd>
7873:
7874: <dt>A start tag whose tag name is "noframes"</dt>
7875: <dd>
7876: <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
7877: mode</a>.</p>
7878: </dd>
7879:
7880: <dt>An end-of-file token</dt>
7881: <dd>
7882:
7883: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7884: <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 7885: error</a>.</p>
7886:
7887: <p class="note">It can only be the <a href="#current-node">current node</a> in
7888: the <a href="#fragment-case">fragment case</a>.</p>
7889:
7890: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7891:
7892: </dd>
7893:
7894: <dt>Anything else</dt>
7895: <dd>
7896: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7897: </dd>
7898:
1.895 mike 7899: </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 7900:
7901: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
7902: mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
7903:
7904: <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
7905: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7906: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7907: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7908: <dd>
7909: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7910: the <a href="#current-node">current node</a>.</p>
7911: </dd>
7912:
7913: <dt>A comment token</dt>
7914: <dd>
1.882 mike 7915: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7916: node</a> with the <code title="">data</code> attribute set to
7917: the data given in the comment token.</p>
7918: </dd>
7919:
7920: <dt>A DOCTYPE token</dt>
7921: <dd>
7922: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7923: </dd>
7924:
7925: <dt>A start tag whose tag name is "html"</dt>
7926: <dd>
7927: <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
7928: mode</a>.</p>
7929: </dd>
7930:
7931: <dt>An end tag whose tag name is "html"</dt>
7932: <dd>
7933: <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
7934: frameset</a>".</p>
7935: </dd>
7936:
7937: <dt>A start tag whose tag name is "noframes"</dt>
7938: <dd>
7939: <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
7940: mode</a>.</p>
7941: </dd>
7942:
7943: <dt>An end-of-file token</dt>
7944: <dd>
7945: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7946: </dd>
7947:
7948: <dt>Anything else</dt>
7949: <dd>
7950: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7951: </dd>
7952:
1.895 mike 7953: </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 7954:
7955: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
7956: mode: after after body">after after body</a>", tokens must be handled as follows:</p>
7957:
7958: <dl class="switch"><dt>A comment token</dt>
7959: <dd>
1.882 mike 7960: <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 7961: object with the <code title="">data</code> attribute set to the
7962: data given in the comment token.</p>
7963: </dd>
7964:
7965: <dt>A DOCTYPE token</dt>
7966: <dt>A character token that is one of U+0009 CHARACTER
7967: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7968: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7969: <dt>A start tag whose tag name is "html"</dt>
7970: <dd>
7971: <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
7972: mode</a>.</p>
7973: </dd>
7974:
7975: <dt>An end-of-file token</dt>
7976: <dd>
7977: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7978: </dd>
7979:
7980: <dt>Anything else</dt>
7981: <dd>
7982: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7983: to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
7984: reprocess the token.</p>
7985: </dd>
7986:
1.895 mike 7987: </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 7988:
7989: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
7990: mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
7991:
7992: <dl class="switch"><dt>A comment token</dt>
7993: <dd>
1.882 mike 7994: <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 7995: object with the <code title="">data</code> attribute set to the
7996: data given in the comment token.</p>
7997: </dd>
7998:
7999: <dt>A DOCTYPE token</dt>
8000: <dt>A character token that is one of U+0009 CHARACTER
8001: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 8002: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 8003: <dt>A start tag whose tag name is "html"</dt>
8004: <dd>
8005: <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
8006: mode</a>.</p>
8007: </dd>
8008:
8009: <dt>An end-of-file token</dt>
8010: <dd>
8011: <p><a href="#stop-parsing">Stop parsing</a>.</p>
8012: </dd>
8013:
8014: <dt>A start tag whose tag name is "noframes"</dt>
8015: <dd>
8016: <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
8017: mode</a>.</p>
8018: </dd>
8019:
8020: <dt>Anything else</dt>
8021: <dd>
8022: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
8023: </dd>
8024:
1.266 mike 8025: </dl></div><div class="impl">
8026:
1.895 mike 8027: <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 8028:
8029: <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484 mike 8030: the document, the user agent must run the following steps:</p>
1.1 mike 8031:
1.484 mike 8032: <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
8033: "interactive" <!-- this also synchronously fires an event --> and
8034: the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
8035:
1.838 mike 8036: <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
8037: elements</a>.</p></li>
8038:
1.484 mike 8039: <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
8040: document has finished parsing</a> is not empty, run these
8041: substeps:</p>
8042:
1.794 mike 8043: <ol><li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the first
1.484 mike 8044: <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
8045: execute when the document has finished parsing</a> has its
8046: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
8047: is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
8048: blocking scripts</a>.</p></li>
8049:
8050: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
8051: 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
8052: execute when the document has finished parsing</a>.</p></li>
8053:
8054: <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
8055: <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
8056: finished parsing</a> (i.e. shift out the first entry in the
8057: list).</p></li>
1.920 mike 8058:
1.484 mike 8059: <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
8060: document has finished parsing</a> is still not empty, repeat
8061: these substeps again from substep 1.</p>
8062:
8063: </li></ol></li>
8064:
1.794 mike 8065: <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 8066: event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
1.810 mike 8067: <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484 mike 8068:
1.879 mike 8069: <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 8070: scripts that will execute as soon as possible</a> is
8071: empty.</p></li> <!-- this step is redundant with the next one,
8072: really, since all those scripts also delay the load event. It's
8073: here in case we add an event between this step and the next or if
8074: we move the previous step (DOMContentLoaded) down again. -->
8075:
1.794 mike 8076: <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
1.484 mike 8077: <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
1.810 mike 8078: the <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484 mike 8079:
1.794 mike 8080: <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 8081: readiness</a> to "complete". <!-- this also fires an event
8082: synchronously during the task --></p></li>
1.1 mike 8083:
1.810 mike 8084: <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 8085: 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 8086: simple event</a> named <code title="event-load">load</code> at
1.810 mike 8087: 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 8088: its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
1.810 mike 8089: <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 8090: <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1 mike 8091:
1.810 mike 8092: <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 8093: 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
8094: <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 8095: its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
1.852 mike 8096: <code><a href="infrastructure.html#document">Document</a></code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
8097: <code><a href="browsers.html#window">Window</a></code> object), using the
8098: <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>
8099: attribute set to false. This event must not bubble, must not be
8100: cancelable, and has no default action.</p></li>
1.569 mike 8101:
1.810 mike 8102: <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 8103: 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 8104: <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 8105: <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
8106: current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484 mike 8107: must bubble but not be cancelable and has no default
8108: action.</p></li>
1.1 mike 8109:
1.810 mike 8110: <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 8111: 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 8112: the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application cache download process
8113: tasks</a>, and then empty the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application
1.794 mike 8114: cache download process tasks</a>. The <a href="webappapis.html#task-source">task source</a>
8115: for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the
8116: <a href="webappapis.html#networking-task-source">networking task source</a>.</p></li>
1.725 mike 8117:
1.810 mike 8118: <li><p>The <code><a href="infrastructure.html#document">Document</a></code> is now <dfn id="completely-loaded">completely
1.725 mike 8119: loaded</dfn>.</p></li>
8120:
1.838 mike 8121: </ol><p>When the user agent is to <dfn id="abort-an-html-parser">abort an HTML parser</dfn>, it
8122: must run the following steps:</p>
8123:
8124: <ol><li><p>Throw away any pending content in the <a href="#the-input-stream">input
8125: stream</a>, and discard any future content that would have been
8126: added to it.</p></li>
8127:
8128: <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
8129: elements</a>.</p></li>
8130:
8131: <!-- anything else? this is things that happen when you call
8132: document.open() on a document that's still being parsed. Should the
8133: pending scripts be blown away or anything? -->
8134:
1.794 mike 8135: </ol><p>Except where otherwise specified, the <a href="webappapis.html#task-source">task source</a>
8136: for the <a href="webappapis.html#concept-task" title="concept-task">tasks</a> mentioned in this
8137: section is the <a href="webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1 mike 8138:
1.266 mike 8139: </div><div class="impl">
1.1 mike 8140:
1.895 mike 8141: <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 8142:
8143: <p>When an application uses an <a href="#html-parser">HTML parser</a> in
8144: conjunction with an XML pipeline, it is possible that the
8145: constructed DOM is not compatible with the XML tool chain in certain
8146: subtle ways. For example, an XML toolchain might not be able to
8147: represent attributes with the name <code title="">xmlns</code>,
8148: since they conflict with the Namespaces in XML syntax. There is also
8149: some data that the <a href="#html-parser">HTML parser</a> generates that isn't
8150: included in the DOM itself. This section specifies some rules for
8151: handling these issues.</p>
8152:
8153: <p>If the XML API being used doesn't support DOCTYPEs, the tool may
8154: drop DOCTYPEs altogether.</p>
8155:
8156: <p>If the XML API doesn't support attributes in no namespace that
8157: are named "<code title="">xmlns</code>", attributes whose names
8158: start with "<code title="">xmlns:</code>", or attributes in the
1.724 mike 8159: <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
1.1 mike 8160: attributes.</p>
8161:
8162: <p>The tool may annotate the output with any namespace declarations
8163: required for proper operation.</p>
8164:
8165: <p>If the XML API being used restricts the allowable characters in
8166: the local names of elements and attributes, then the tool may map
8167: all element and attribute local names that the API wouldn't support
8168: to a set of names that <em>are</em> allowed, by replacing any
8169: character that isn't supported with the uppercase letter U and the
8170: six digits of the character's Unicode code point when expressed in
8171: hexadecimal, using digits 0-9 and capital letters A-F as the
8172: symbols, in increasing numeric order.</p>
8173:
8174: <p class="example">For example, the element name <code title="">foo<bar</code>, which can be output by the <a href="#html-parser">HTML
8175: parser</a>, though it is neither a legal HTML element name nor a
8176: well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
8177: element name (though it's still not legal in HTML by any means).</p>
8178:
8179: <p class="example">As another example, consider the attribute
8180: <code>xlink:href</code>. Used on a MathML element, it becomes, after
8181: being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
8182: attribute with a prefix "<code title="">xlink</code>" and a local
8183: name "<code title="">href</code>". However, used on an HTML element,
8184: it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
8185: might not be accepted by an XML API. It could thus get converted,
8186: becoming "<code title="">xlinkU00003Ahref</code>".</p>
8187:
8188: <p class="note">The resulting names from this conversion
8189: conveniently can't clash with any attribute generated by the
8190: <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
8191: those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
8192: algorithm's table.</p>
8193:
8194: <p>If the XML API restricts comments from having two consecutive
8195: U+002D HYPHEN-MINUS characters (--), the tool may insert a single
8196: U+0020 SPACE character between any such offending characters.</p>
8197:
8198: <p>If the XML API restricts comments from ending in a
8199: U+002D HYPHEN-MINUS character (-), the tool may insert a single
8200: U+0020 SPACE character at the end of such comments.</p>
8201:
8202: <p>If the XML API restricts allowed characters in character data,
1.439 mike 8203: attribute values, or comments, the tool may replace any U+000C FORM
8204: FEED (FF) character with a U+0020 SPACE character, and any other
8205: literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1 mike 8206:
8207: <p>If the tool has no way to convey out-of-band information, then
8208: the tool may drop the following information:</p>
8209:
1.880 mike 8210: <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no-quirks mode</a></i>,
8211: <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 8212:
8213: <li>The association between form controls and forms that aren't
8214: their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
8215: <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
8216:
8217: </ul><p class="note">The mutations allowed by this section apply
8218: <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
8219: applied. For example, a <code title=""><a::></code> start tag
8220: will be closed by a <code title=""></a::></code> end tag, and
8221: never by a <code title=""></aU00003AU00003A></code> end tag, even
8222: if the user agent is using the rules above to then generate an
8223: actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
8224:
1.266 mike 8225: </div><div class="impl">
1.1 mike 8226:
1.895 mike 8227: <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 8228:
8229: <p><i>This section is non-normative.</i></p>
8230:
8231: <p>This section examines some erroneous markup and discusses how
8232: the <a href="#html-parser">HTML parser</a> handles these cases.</p>
8233:
8234:
1.755 mike 8235: <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 8236:
8237: <p><i>This section is non-normative.</i></p>
8238:
8239: <p>The most-often discussed example of erroneous markup is as
8240: follows:</p>
8241:
8242: <pre><p>1<b>2<i>3</b>4</i>5</p></pre>
8243:
8244: <p>The parsing of this markup is straightforward up to the "3". At
8245: this point, the DOM looks like this:</p>
8246:
1.159 mike 8247: <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
8248: 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 8249: <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
8250: formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
8251: <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>
8252:
8253: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
8254: invoked. This is a simple case, in that the <var title="">formatting
8255: element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
8256: <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8257: elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8258: <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 8259: active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
8260: DOM tree is unmodified at this point.</p>
8261:
8262: <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
8263: the active formatting elements</a>, in this case just the
8264: <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
8265: for the "4" text node. After the end tag token for the "i" is also
8266: received, and the "5" text node is inserted, the DOM looks as
8267: follows:</p>
8268:
1.755 mike 8269: <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="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 8270:
8271: <p><i>This section is non-normative.</i></p>
8272:
8273: <p>A case similar to the previous one is the following:</p>
8274:
8275: <pre><b>1<p>2</b>3</p></pre>
8276:
8277: <p>Up to the "2" the parsing here is straightforward:</p>
8278:
1.159 mike 8279: <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 8280: "b" is parsed.</p>
8281:
8282: <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8283: elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8284: <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 8285: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
8286: <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>
8287:
8288: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
8289: in the previous example. However, in this case, there <em>is</em> a
8290: <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
8291: this time the adoption agency algorithm isn't skipped over.</p>
8292:
1.159 mike 8293: <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 8294: element. A conceptual "bookmark" marks the position of the
8295: <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
8296: elements</a>, but since that list has only one element in it,
8297: it won't have much effect.</p>
8298:
8299: <p>As the algorithm progresses, <var title="">node</var> ends up set
8300: to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
8301: node</var> ends up set to the <var title="">furthest block</var>
8302: (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
8303:
8304: <p>The <var title="">last node</var> gets appended (moved) to the
8305: <var title="">common ancestor</var>, so that the DOM looks like:</p>
8306:
1.159 mike 8307: <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 8308: <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
8309:
1.159 mike 8310: <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 8311: <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
8312:
1.159 mike 8313: <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="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 8314: active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
8315: elements</a>, so that when the "3" is parsed, it is appended to
8316: the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
8317:
1.895 mike 8318: <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 8319:
8320: <p><i>This section is non-normative.</i></p>
8321:
8322: <p>Error handling in tables is, for historical reasons, especially
8323: strange. For example, consider the following markup:</p>
8324:
8325: <pre><table><strong><b></strong><tr><td>aaa</td></tr><strong>bbb</strong></table>ccc</pre>
8326:
8327: <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
8328: directly inside a table like that, and the parser handles this case
8329: 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
8330: examining the DOM tree as it stands just after the
8331: <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
8332:
1.159 mike 8333: <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 8334: tag has been seen:</p>
8335:
1.159 mike 8336: <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
8337: 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 8338: <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
8339: resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
8340: elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
8341: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
8342: table">in table</a>".</p>
8343:
8344: <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
8345: to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
8346: 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
8347: then handled in a rather straight-forward manner, taking the parser
8348: through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
8349: body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
8350: row</a>" insertion modes, after which the DOM looks as
8351: follows:</p>
8352:
1.159 mike 8353: <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
8354: 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 8355: <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
8356: formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
8357: it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
8358: mode: in row">in row</a>".</p>
8359:
8360: <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
8361: <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
8362: 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
8363: mode</a>).</p>
8364:
1.159 mike 8365: <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 8366: no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
8367: node:</p>
8368:
1.159 mike 8369: <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 8370: handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159 mike 8371: 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 8372: 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
8373: elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
8374: marker having been removed by the "td" end tag token); and the
8375: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
8376: table body">in table body</a>".</p>
8377:
8378: <p>Thus it is that the "bbb" character tokens are found. These
8379: trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
8380: text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
8381: insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
8382: body">in table body</a>"). The character tokens are collected,
8383: and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
8384: seen, they are processed as a group. Since they are not all spaces,
8385: 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,
8386: which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
8387: body</a>" insertion mode but with <a href="#foster-parent" title="foster
8388: parent">foster parenting</a>.</p>
8389:
8390: <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
8391: active formatting elements are reconstructed</a>, a
8392: <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
8393: parent">foster parented</a>, and then the "bbb" text node is
8394: appended to it:</p>
8395:
1.159 mike 8396: <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
8397: <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 8398: <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
8399: this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
8400: formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
8401: and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
8402: mode: in table body">in table body</a>".</p>
8403:
8404: <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
8405: character">space characters</a> instead of "bbb", then those
8406: <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
8407: appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
8408:
8409: <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
8410: tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
8411: elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
8412: but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
8413: elements</a>, so the "ccc" character tokens after the table
8414: result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
8415: time after the table:</p>
8416:
1.895 mike 8417: <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 8418:
8419: <p><i>This section is non-normative.</i></p>
8420:
8421: <p>Consider the following markup, which for this example we will
8422: 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 8423: content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1 mike 8424: <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
8425:
8426: <pre><div id=a>
8427: <script>
8428: var div = document.getElementById('a');
8429: parent.document.body.appendChild(div);
8430: </script>
8431: <script>
8432: alert(document.URL);
8433: </script>
8434: </div>
8435: <script>
8436: alert(document.URL);
8437: </script></pre>
8438:
8439: <p>Up to the first "script" end tag, before the script is parsed,
8440: the result is relatively straightforward:</p>
8441:
1.306 mike 8442: <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="">
8443: </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 8444: and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
8445:
1.810 mike 8446: <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 8447: aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
8448: <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306 mike 8449: <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1 mike 8450:
8451: <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
1.810 mike 8452: is inserted <em>into the outer <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 8453: object</em>.</p>
8454:
1.794 mike 8455: <p>This also means that the <a href="webappapis.html#script-s-global-object">script's global object</a> is
1.1 mike 8456: the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
8457: object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159 mike 8458: <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1 mike 8459:
8460: <p class="note">This isn't a security problem since the script that
1.810 mike 8461: 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
8462: only do so because the two <code><a href="infrastructure.html#document">Document</a></code> object have the
1.714 mike 8463: same <a href="browsers.html#origin">origin</a>.</p>
1.1 mike 8464:
8465: <p>Thus, the first alert says "http://example.com/outer".</p>
8466:
1.306 mike 8467: <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
8468: <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.810 mike 8469: <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 8470:
1.159 mike 8471: <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 8472:
8473:
8474:
8475:
1.895 mike 8476: <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 8477:
8478: <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
8479: algorithm</dfn>. The algorithm takes as input a DOM
1.810 mike 8480: <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 8481: exception.</p>
8482:
8483: <p class="note">This algorithm serializes the <em>children</em> of
8484: the node being serialized, not the node itself.</p>
8485:
8486: <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
8487: the empty string.</p></li>
8488:
8489: <li>
8490:
8491: <p>For each child node of <var title="">the node</var>, in
8492: <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
8493:
8494: </p><ol><li><p>Let <var title="">current node</var> be the child node
8495: being processed.</p></li>
8496:
8497: <li>
8498:
8499: <p>Append the appropriate string from the following list to
8500: <var title="">s</var>:</p>
8501:
8502: <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
8503:
8504: <dd>
8505:
1.588 mike 8506: <p>Append a U+003C LESS-THAN SIGN character character (<),
8507: followed by the element's tag name. (For nodes created by the
8508: <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1 mike 8509: lowercase.)</p>
8510:
8511: <p>For each attribute that the element has, append a U+0020
8512: SPACE character, the attribute's name (which, for attributes
8513: 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 8514: U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
8515: character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
8516: <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
8517: character (").</p>
1.1 mike 8518:
8519: <p>While the exact order of attributes is UA-defined, and may
8520: depend on factors such as the order that the attributes were
8521: given in the original markup, the sort order must be stable,
8522: such that consecutive invocations of this algorithm serialize an
8523: element's attributes in the same order.</p>
8524:
1.588 mike 8525: <p>Append a U+003E GREATER-THAN SIGN character (>).</p>
1.1 mike 8526:
8527: <p>If <var title="">current node</var> is an
1.5 mike 8528: <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 8529: <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 8530: <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>,
8531: <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 8532: <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 8533: <code><a href="text-level-semantics.html#the-wbr-element">wbr</a></code> element, then continue on to the next child
1.589 mike 8534: node at this point.</p> <!-- also, i guess: image and isindex,
8535: but we don't list those because we don't consider those
8536: "elements", more "macros", and thus we should never serialize
8537: them -->
1.1 mike 8538:
8539: <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42 mike 8540: <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 8541: a U+000A LINE FEED (LF) character.</p>
8542:
8543: <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
8544: serialization algorithm</a> on the <var title="">current
8545: node</var> element (thus recursing into this algorithm for
1.588 mike 8546: that element), followed by a U+003C LESS-THAN SIGN character
8547: (<), a U+002F SOLIDUS character (/), the element's tag name
8548: again, and finally a U+003E GREATER-THAN SIGN character
8549: (>).</p>
1.1 mike 8550:
8551: </dd>
8552:
8553:
8554: <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
8555: node</dt>
8556:
8557: <dd>
8558:
1.19 mike 8559: <p>If the parent of <var title="">current node</var> is a
1.42 mike 8560: <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 8561: <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 8562: <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
8563: if the parent of <var title="">current node</var> is
1.794 mike 8564: <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 8565: node, then append the value of <var title="">current
8566: node</var>'s <code title="">data</code> IDL attribute
8567: literally.</p>
1.1 mike 8568:
8569: <p>Otherwise, append the value of <var title="">current
1.192 mike 8570: node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1 mike 8571: below</a>.</p>
8572:
8573: </dd>
8574:
8575:
8576: <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
8577:
8578: <dd>
8579:
8580: <p>Append the literal string <code><!--</code> (U+003C
8581: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192 mike 8582: U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8583: attribute, followed by the literal string <code>--></code>
8584: (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
8585: SIGN).</p>
8586:
8587: </dd>
8588:
8589:
8590: <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
8591:
8592: <dd>
8593:
8594: <p>Append the literal string <code><?</code> (U+003C
8595: LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192 mike 8596: of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
8597: U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8598: attribute, followed by a single U+003E GREATER-THAN SIGN
1.464 mike 8599: character (>).</p>
1.1 mike 8600:
8601: </dd>
8602:
8603:
8604: <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
8605:
8606: <dd>
8607:
8608: <p>Append the literal string <code><!DOCTYPE</code> (U+003C
8609: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
8610: LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
8611: LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
8612: LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
8613: LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192 mike 8614: value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1 mike 8615: string <code>></code> (U+003E GREATER-THAN SIGN).</p>
8616:
8617: </dd>
8618:
8619:
8620: </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
8621: occur as children of elements. If, despite this, they somehow do
8622: occur, this algorithm must raise an
8623: <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
8624:
8625: </li>
8626:
8627: </ol></li>
8628:
8629: <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
8630:
8631: </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
8632: purposes of the algorithm above) consists of replacing any
8633: occurrences of the "<code title="">&</code>" character by the
8634: string "<code title="">&amp;</code>", any occurrences of the
8635: U+00A0 NO-BREAK SPACE character by the string "<code title="">&nbsp;</code>", and, if the algorithm was invoked in
8636: 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
8637: 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>
8638:
8639: <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
8640: agent, and are therefore not covered in the algorithm above.</p>
8641:
8642: <p class="note">It is possible that the output of this algorithm, if
8643: parsed with an <a href="#html-parser">HTML parser</a>, will not return the
8644: original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
8645: element to which a <code title="">Comment</code> node has been
8646: appended is serialized and the output is then reparsed, the comment
8647: will end up being displayed in the text field. Similarly, if, as a
8648: result of DOM manipulation, an element contains a comment that
8649: contains the literal string "<code title="">--></code>", then
8650: when the result of serializing the element is parsed, the comment
8651: will be truncated at that point and the rest of the comment will be
8652: interpreted as markup. More examples would be making a
8653: <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
8654: "<code></script></code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
8655: 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
8656: <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
8657: tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
8658:
8659:
1.895 mike 8660: <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 8661:
8662: <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
8663: algorithm</dfn>. The algorithm optionally takes as input an
1.810 mike 8664: <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 8665: parser, as well as <var title="">input</var>, a string to parse, and
8666: returns a list of zero or more nodes.</p>
8667:
8668: <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
8669: in the parser section are parts that only occur if the parser was
8670: created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
8671: with such markings for informational purposes only; such markings
8672: have no normative weight. If it is possible for a condition
8673: described as a <a href="#fragment-case">fragment case</a> to occur even when the
8674: parser wasn't created for the purposes of handling this algorithm,
8675: then that is an error in the specification.</p>
8676:
8677: <ol><li>
8678:
1.810 mike 8679: <p>Create a new <code><a href="infrastructure.html#document">Document</a></code> node, and mark it as being
1.1 mike 8680: an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
8681:
8682: </li>
8683:
8684: <li>
8685:
8686: <p>If there is a <var title="">context</var> element, and the
1.810 mike 8687: <code><a href="infrastructure.html#document">Document</a></code> of the <var title="">context</var> element
8688: is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code>
8689: 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 8690: the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited-quirks
1.810 mike 8691: mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code> be in
1.880 mike 8692: <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>. Otherwise, leave the
8693: <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 8694:
8695: </li>
8696:
8697: <li>
8698:
8699: <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
1.810 mike 8700: the just created <code><a href="infrastructure.html#document">Document</a></code> node.</p>
1.1 mike 8701:
8702: </li>
8703:
8704: <li>
8705:
8706: <p>If there is a <var title="">context</var> element, run these
8707: substeps:</p>
8708:
8709: <ol><li>
8710:
1.541 mike 8711: <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
8712: <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1 mike 8713:
1.159 mike 8714: <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 8715: element</dt>
8716:
1.541 mike 8717: <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 8718:
8719:
1.672 mike 8720: <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>,
8721: <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 8722: <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1 mike 8723:
1.541 mike 8724: <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 8725:
8726:
1.672 mike 8727: <dt>If it is a <code><a href="semantics.html#script">script</a></code> element</dt>
8728:
8729: <dd>Switch the tokenizer to the <a href="#script-data-state">script data state</a>.</dd>
8730:
8731:
1.1 mike 8732: <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
8733:
1.541 mike 8734: <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
8735: tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>. Otherwise,
8736: leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8737:
8738:
1.42 mike 8739: <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1 mike 8740:
1.541 mike 8741: <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
8742: state</a>.</dd>
1.1 mike 8743:
8744:
8745: <dt>Otherwise</dt>
8746:
1.541 mike 8747: <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8748:
1.672 mike 8749: </dl><p class="note">For performance reasons, an implementation that
1.756 mike 8750: does not report errors and that uses the actual state machine
8751: described in this specification directly could use the PLAINTEXT
8752: state instead of the RAWTEXT and script data states where those
8753: are mentioned in the list above. Except for rules regarding
8754: parse errors, they are equivalent, since there is no
8755: <a href="#appropriate-end-tag-token">appropriate end tag token</a> in the fragment case, yet
8756: they involve far fewer state transitions.</p>
1.672 mike 8757:
8758: </li>
1.1 mike 8759:
8760: <li>
8761:
1.159 mike 8762: <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 8763: with no attributes.</p>
8764:
8765: </li>
8766:
8767: <li>
8768:
8769: <p>Append the element <var title="">root</var> to the
1.810 mike 8770: <code><a href="infrastructure.html#document">Document</a></code> node created above.</p>
1.1 mike 8771:
8772: </li>
8773:
8774: <li>
8775:
8776: <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
8777: it contains just the single element <var title="">root</var>.</p>
8778:
8779: </li>
8780:
8781: <li>
8782:
8783: <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
8784: parser's insertion mode appropriately</a>.</p>
8785:
8786: <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
8787:
8788: </li>
8789:
8790: <li>
8791:
8792: <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
8793: to the nearest node to the <var title="">context</var> element
8794: that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
8795: ancestor chain, and including the element itself, if it is a
8796: <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
8797: <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
8798:
8799: </li>
8800:
8801: </ol></li>
8802:
8803: <li>
8804:
8805: <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
8806: parser</a> just created the <var title="">input</var>. The
8807: encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
8808: <i>irrelevant</i>.</p>
8809:
8810: </li>
8811:
8812: <li>
8813:
8814: <p>Start the parser and let it run until it has consumed all the
8815: characters just inserted into the input stream.</p>
8816:
8817: </li>
8818:
8819: <li>
8820:
8821: <p>If there is a <var title="">context</var> element, return the
8822: child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
8823: order</a>.</p>
8824:
1.810 mike 8825: <p>Otherwise, return the children of the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 8826: object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
8827:
8828: </li>
8829:
1.123 mike 8830: </ol></div></body></html>
Webmaster