Annotation of html5/spec/syntax.html, revision 1.853
1.2 mike 1: <!DOCTYPE HTML>
1.755 mike 2: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><head><title>8 The HTML syntax — HTML 5</title><style type="text/css">
1.1 mike 3: pre { margin-left: 2em; white-space: pre-wrap; }
4: h2 { margin: 3em 0 1em 0; }
5: h3 { margin: 2.5em 0 1em 0; }
6: h4 { margin: 2.5em 0 0.75em 0; }
7: h5, h6 { margin: 2.5em 0 1em; }
8: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
9: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
10: p { margin: 1em 0; }
11: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
12: dl, dd { margin-top: 0; margin-bottom: 0; }
13: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
14: dt + dt { margin-top: 0; }
15: dd dt { margin-top: 0.25em; margin-bottom: 0; }
16: dd p { margin-top: 0; }
17: dd dl + p { margin-top: 1em; }
18: dd table + p { margin-top: 1em; }
19: p + * > li, dd li { margin: 1em 0; }
20: dt, dfn { font-weight: bold; font-style: normal; }
21: dt dfn { font-style: italic; }
22: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
23: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
24: pre em { font-weight: bolder; font-style: normal; }
25: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
26: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
27: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
28: table thead { border-bottom: solid; }
29: table tbody th:first-child { border-left: solid; }
1.475 mike 30: table tbody th { text-align: left; }
1.1 mike 31: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
32: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
33:
34: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
35: .matrix, .matrix td { border: none; text-align: right; }
36: .matrix { margin-left: 2em; }
37: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
38: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
39: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
40:
41: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
42: img.extra { float: right; }
43: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
44: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
45: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
46: pre.css:first-line { color: #AAAA50; }
1.840 mike 47: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1 mike 48: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
49: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
50: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
51: dl.domintro dd p { margin: 0.5em 0; }
52: dl.switch { padding-left: 2em; }
53: dl.switch > dt { text-indent: -1.5em; }
54: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
55: dl.triple { padding: 0 0 0 1em; }
56: dl.triple dt, dl.triple dd { margin: 0; display: inline }
57: dl.triple dt:after { content: ':'; }
58: dl.triple dd:after { content: '\A'; white-space: pre; }
59: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
60: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
61: a .diff-new { border-bottom: 1px blue solid; }
62:
63: h2 { page-break-before: always; }
64: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
65: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
66:
67: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
68:
69: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
70: div.head p { margin: 0; }
71: div.head h1 { margin: 0; }
72: div.head .logo { float: right; margin: 0 1em; }
73: div.head .logo img { border: none } /* remove border from top image */
74: div.head dl { margin: 1em 0; }
1.671 mike 75: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1 mike 76:
77: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
78: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
79: body > .toc > li > * { margin-bottom: 0.5em; }
80: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
81: .toc, .toc li { list-style: none; }
82:
83: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
84: .brief li { margin: 0; padding: 0; }
85: .brief li p { margin: 0; padding: 0; }
86:
87: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
88: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
89: .category-list li { display: inline; }
90: .category-list li:not(:last-child)::after { content: ', '; }
91: .category-list li > span, .category-list li > a { text-transform: lowercase; }
92: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
93:
94: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
95: .XXX > :first-child { margin-top: 0; }
96: p .XXX { line-height: 3em; }
1.159 mike 97: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
98: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
99: .annotation :link, .annotation :visited { color: inherit; }
100: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
101: .annotation span { border: none ! important; }
1.1 mike 102: .note { color: green; background: transparent; font-family: sans-serif; }
103: .warning { color: red; background: transparent; }
104: .note, .warning { font-weight: bolder; font-style: italic; }
105: p.note, div.note { padding: 0.5em 2em; }
106: span.note { padding: 0 2em; }
107: .note p:first-child, .warning p:first-child { margin-top: 0; }
108: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
109: .warning:before { font-style: normal; }
110: p.note:before { content: 'Note: '; }
111: p.warning:before { content: '\26A0 Warning! '; }
112:
113: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
114: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
115: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
116:
117: h4 { position: relative; z-index: 3; }
118: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
119: .element {
120: background: #EEEEFF;
121: color: black;
122: margin: 0 0 1em 0.15em;
123: padding: 0 1em 0.25em 0.75em;
124: border-left: solid #9999FF 0.25em;
125: position: relative;
126: z-index: 1;
127: }
128: .element:before {
129: position: absolute;
130: z-index: 2;
131: top: 0;
132: left: -1.15em;
133: height: 2em;
134: width: 0.9em;
135: background: #EEEEFF;
136: content: ' ';
137: border-style: none none solid solid;
138: border-color: #9999FF;
139: border-width: 0.25em;
140: }
141:
1.149 mike 142: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
143: td > .example:only-child { margin: 0 0 0 0.1em; }
1.1 mike 144:
145: .tall-and-narrow {
146: font-size: 0.6em;
147: column-width: 25em;
148: column-gap: 1em;
149: -moz-column-width: 25em;
150: -moz-column-gap: 1em;
151: -webkit-column-width: 25em;
152: -webkit-column-gap: 1em;
153: }
154:
155: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
156: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
157: ul.domTree li li { list-style: none; }
158: ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
159: ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
160: ul.domTree span { font-style: italic; font-family: serif; }
161: ul.domTree .t1 code { color: purple; font-weight: bold; }
162: ul.domTree .t2 { font-style: normal; font-family: monospace; }
163: ul.domTree .t2 .name { color: black; font-weight: bold; }
164: ul.domTree .t2 .value { color: blue; font-weight: normal; }
165: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
166: ul.domTree .t7 code, .domTree .t8 code { color: green; }
167: ul.domTree .t10 code { color: teal; }
168:
1.736 mike 169: body.dfnEnabled dfn { cursor: pointer; }
170: .dfnPanel {
171: display: inline;
172: position: absolute;
173: z-index: 10;
174: height: auto;
175: width: auto;
176: padding: 0.5em 0.75em;
177: font: small sans-serif, Droid Sans Fallback;
178: background: #DDDDDD;
179: color: black;
180: border: outset 0.2em;
181: }
182: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
183: .dfnPanel :link, .dfnPanel :visited { color: black; }
184: .dfnPanel p { font-weight: bolder; }
185: .dfnPanel * + p { margin-top: 0.25em; }
186: .dfnPanel li { list-style-position: inside; }
187:
1.671 mike 188: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
189: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
190: #configUI p label { display: block; }
191: #configUI #updateUI, #configUI .loginUI { text-align: center; }
192: #configUI input[type=button] { display: block; margin: auto; }
1.267 mike 193: </style><style type="text/css">
194:
1.292 mike 195: .applies thead th > * { display: block; }
196: .applies thead code { display: block; }
197: .applies tbody th { whitespace: nowrap; }
198: .applies td { text-align: center; }
199: .applies .yes { background: yellow; }
200:
1.267 mike 201: .matrix, .matrix td { border: none; text-align: right; }
202: .matrix { margin-left: 2em; }
203:
204: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
205: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
206: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
207:
208: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
209: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
210: #table-example-1 caption { padding-bottom: 0.5em; }
211: #table-example-1 thead, #table-example-1 tbody { border: none; }
212: #table-example-1 th, #table-example-1 td { border: solid thin; }
213: #table-example-1 th { font-weight: normal; }
214: #table-example-1 td { border-style: none solid; vertical-align: top; }
215: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
216: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
217: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
218: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
219: #table-example-1 tbody td:first-child::after { content: leader(". "); }
220: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
221: #table-example-1 tbody td:first-child + td { width: 10em; }
222: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
223: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
224:
225: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
226: .apple-table-examples * { font-family: "Times", serif; }
227: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
228: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
229: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
230: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
231: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
232: .apple-table-examples td { text-align: right; vertical-align: top; }
233: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
234: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
235: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
236: .apple-table-examples sup { line-height: 0; }
237:
1.724 mike 238: .details-example img { vertical-align: top; }
239:
1.840 mike 240: </style><style>
241: .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: red; border: solid 2px; background: white; padding: 0 0.25em; }
242: </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" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.671 mike 243: function getCookie(name) {
244: var params = location.search.substr(1).split("&");
245: for (var index = 0; index < params.length; index++) {
246: if (params[index] == name)
247: return "1";
248: var data = params[index].split("=");
249: if (data[0] == name)
250: return unescape(data[1]);
251: }
252: var cookies = document.cookie.split("; ");
253: for (var index = 0; index < cookies.length; index++) {
254: var data = cookies[index].split("=");
255: if (data[0] == name)
256: return unescape(data[1]);
257: }
258: return null;
259: }
260: function load(script) {
261: var e = document.createElement('script');
262: e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
263: document.body.appendChild(e);
264: }
265: function init() {
266: if (location.search == '?slow-browser')
267: return;
268: var configUI = document.createElement('div');
269: configUI.id = 'configUI';
270: document.body.appendChild(configUI);
271: // load('reviewer.js'); // would need cross-site XHR
272: if (document.getElementById('head'))
273: load('toc.js');
274: load('styler.js');
275: // load('updater.js'); // would need cross-site XHR
1.724 mike 276: load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.671 mike 277: // load('status.js'); // would need cross-site XHR
278: if (getCookie('profile') == '1')
279: document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
280: fixBrokenLink();
281: }
1.808 mike 282: </script><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css">
1.2 mike 283: <script src="link-fixup.js"></script>
1.755 mike 284: <link href="editing.html" title="7 User interaction" rel="prev">
1.2 mike 285: <link href="spec.html#contents" title="Table of contents" rel="index">
1.755 mike 286: <link href="named-character-references.html" title="8.5 Named character references" rel="next">
1.671 mike 287: </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1 mike 288: <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 289: <h1>HTML5</h1>
1.1 mike 290: <h2 class="no-num no-toc" id="a-vocabulary-and-associated-apis-for-html-and-xhtml">A vocabulary and associated APIs for HTML and XHTML</h2>
1.123 mike 291: </div><nav>
1.755 mike 292: <a href="editing.html">← 7 User interaction</a> –
1.2 mike 293: <a href="spec.html#contents">Table of contents</a> –
1.755 mike 294: <a href="named-character-references.html">8.5 Named character references →</a>
1.853 ! mike 295: </nav><p>This is revision 1.3849.</p>
1.659 mike 296:
1.1 mike 297:
1.755 mike 298: <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 299: labeled with an <a href="infrastructure.html#html-mime-type">HTML MIME type</a>. Rules for XML resources
300: are discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.755 mike 301: 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 302:
303: <p><i>This section only applies to documents, authoring tools, and
304: markup generators. In particular, it does not apply to conformance
305: checkers; conformance checkers must use the requirements given in
306: the next section ("parsing HTML documents").</i></p>
307:
1.123 mike 308: </div><p>Documents must consist of the following parts, in the given
309: order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1 mike 310:
311: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
312: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
313:
314: <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
315:
316: </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
317: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
318:
1.159 mike 319: <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 320:
321: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
322: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
323:
324: </ol><p>The various types of content mentioned above are described in the
1.123 mike 325: 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 326: declarations</a> are to be serialized, as discussed in the
1.123 mike 327: section on that topic.</p><div class="note">
1.1 mike 328:
1.159 mike 329: <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
330: space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
331: before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1 mike 332: document is parsed; space characters <em>after</em> the root
1.159 mike 333: <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
334: of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1 mike 335: root element do not round-trip.</p>
336:
337: <p>It is suggested that newlines be inserted after the DOCTYPE,
338: after any comments that are before the root element, after the
1.159 mike 339: <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
340: that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
341: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 342:
1.123 mike 343: </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1 mike 344: their attributes) are case-insensitive, but only for characters in
1.547 mike 345: the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
346: LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1 mike 347: LETTER Z). For convenience, in this section this is just referred to
1.813 mike 348: 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 useless,
1.123 mike 349: but required, header.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1 mike 350: omitted, browsers tend to use a different rendering mode that is
351: incompatible with some specifications. Including the DOCTYPE in a
352: document ensures that the browser makes a best-effort attempt at
1.123 mike 353: following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.588 mike 354: order:</p><ol class="brief"><li>A U+003C LESS-THAN SIGN character (<).</li>
355: <li>A U+0021 EXCLAMATION MARK character (!).</li>
1.1 mike 356: <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>
357: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
358: <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">HTML</code>".</li>
359: <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> (defined below).</li>
360: <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.588 mike 361: <li>A U+003E GREATER-THAN SIGN character (>).</li>
1.1 mike 362: </ol><p class="note">In other words, <code><!DOCTYPE HTML></code>,
1.123 mike 363: case-insensitively.</p><p>For the purposes of HTML generators that cannot output HTML
1.1 mike 364: markup with the short DOCTYPE "<code title=""><!DOCTYPE
365: HTML></code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
366: into the DOCTYPE (in the position defined above). This string must
1.123 mike 367: consist of:</p><ol class="brief"><li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 368: <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">SYSTEM</code>".</li>
1.444 mike 369: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 370: <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465 mike 371: <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.1 mike 372: <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step marked <i>quote mark</i>).</li>
373: </ol><p class="note">In other words, <code><!DOCTYPE HTML SYSTEM
374: "about:legacy-compat"></code> or <code><!DOCTYPE HTML SYSTEM
375: 'about:legacy-compat'></code>, case-insensitively except for the bit
1.724 mike 376: in single or double quotes.</p><p>The <a href="#doctype-legacy-string">DOCTYPE legacy string</a> should not be used unless
1.1 mike 377: the document is generated from a system that cannot output the
1.755 mike 378: shorter string.</p><h4 id="elements-0"><span class="secno">8.1.2 </span>Elements</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>There are five different kinds of <dfn id="syntax-elements" title="syntax-elements">elements</dfn>: <a href="#void-elements">void elements</a>,
1.373 mike 379: <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
380: <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 381:
382: <dd><code><a href="the-canvas-element.html#the-area-element">area</a></code>, <code><a href="semantics.html#the-base-element">base</a></code>, <code><a href="semantics.html#the-br-element">br</a></code>,
1.159 mike 383: <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>,
384: <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 385: <code><a href="forms.html#the-keygen-element">keygen</a></code>, <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="semantics.html#meta">meta</a></code>,
1.159 mike 386: <code><a href="text-level-semantics.html#the-param-element">param</a></code>, <code><a href="video.html#the-source-element">source</a></code></dd>
1.1 mike 387:
1.373 mike 388: <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1 mike 389:
390: <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 391: noscript don't count as raw text for syntax purposes -->
1.1 mike 392:
1.373 mike 393: <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1 mike 394:
1.159 mike 395: <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 396:
1.373 mike 397: <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1 mike 398:
1.724 mike 399: <dd>Elements from the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>
400: and the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dd>
1.1 mike 401:
1.373 mike 402: <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1 mike 403:
404: <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
405: elements.</dd>
406:
407: </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373 mike 408: and end of elements in the markup. <a href="#raw-text-elements" title="raw text
409: elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
410: elements">RCDATA</a>, and <a href="#normal-elements" title="normal
411: elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
412: begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
413: indicate where they end. The start and end tags of certain
414: <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 415: later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
416: elements</a> only have a start tag; end tags must not be
1.373 mike 417: specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
418: elements</a> must either have a start tag and an end tag, or a
419: start tag that is marked as self-closing, in which case they must
420: not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1 mike 421: start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
422: in certain cases</a>) and just before the end tag (which again,
423: <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
424: cases</a>). The exact allowed contents of each individual element
425: depends on the content model of that element, as described earlier
426: in this specification. Elements must not contain content that their
427: content model disallows. In addition to the restrictions placed on
428: the contents by those content models, however, the five types of
1.123 mike 429: 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 430: no end tag, no content can be put between the start tag and the end
1.373 mike 431: 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
432: 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
433: must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1 mike 434: There are also <a href="#cdata-rcdata-restrictions">further
1.373 mike 435: restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
436: self-closing can't have any contents (since, again, as there's no
437: end tag, no content can be put between the start tag and the end
438: tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
439: 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 440: 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 441:
442: <p>The HTML syntax does not support namespace
443: declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
444:
445: <p>For instance, consider the following HTML fragment:</p>
446:
447: <pre><p>
448: <svg>
449: <metadata>
450: <!-- this is invalid -->
451: <cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/>
452: </metadata>
453: </svg>
454: </p></pre>
455:
456: <p>The innermost element, <code title="">cdr:license</code>, is
457: actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
458: XML). In fact, as the comment in the fragment above says, the
459: fragment is actually non-conforming. This is because the SVG
460: specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
461:
462: </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 463: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
464: <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1 mike 465: content they are allowed to hold, beyond the restrictions imposed by
466: the content model and those described in this paragraph. Those
1.123 mike 467: restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1 mike 468: giving the element's name. HTML elements all have names that only
1.464 mike 469: use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
470: NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
471: Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
472: Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462 mike 473: elements</a>, may be written with any mix of lower- and uppercase
474: letters that, when converted to all-lowercase, matches the element's
1.755 mike 475: 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 476: following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588 mike 477: SIGN character (<).</li>
1.1 mike 478:
479: <li>The next few characters of a start tag must be the element's
480: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
481:
482: <li>If there are to be any attributes in the next step, there must
483: first be one or more <a href="infrastructure.html#space-character" title="space character">space
484: characters</a>.</li>
485:
486: <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
487: below. Attributes may be separated from each other by one or more
488: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
489:
1.766 mike 490: <li>After the attributes, or after the <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a> if there are no attributes,
491: there may be one or more <a href="infrastructure.html#space-character" title="space character">space
492: characters</a>. (Some attributes are required to be followed by
493: a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes
494: section</a> below.)</li>
1.1 mike 495:
496: <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373 mike 497: or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588 mike 498: element</a>, then there may be a single U+002F SOLIDUS character
499: (/). This character has no effect on <a href="#void-elements">void elements</a>,
500: but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
501: self-closing.</li>
1.1 mike 502:
503: <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588 mike 504: SIGN character (>).</li>
1.1 mike 505:
1.755 mike 506: </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 507: following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588 mike 508: SIGN character (<).</li>
1.1 mike 509:
510: <li>The second character of an end tag must be a U+002F SOLIDUS
1.588 mike 511: character (/).</li>
1.1 mike 512:
513: <li>The next few characters of an end tag must be the element's
514: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
515:
516: <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
517: character">space characters</a>.</li>
518:
1.588 mike 519: <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
520: character (>).</li>
1.1 mike 521:
1.755 mike 522: </ol><h5 id="attributes"><span class="secno">8.1.2.3 </span>Attributes</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-attributes" title="syntax-attributes">Attributes</dfn> for an element
1.123 mike 523: 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 524: one or more characters other than the <a href="infrastructure.html#space-character" title="space
525: character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
526: MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
527: (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
528: the control characters, and any characters that are not defined by
1.462 mike 529: Unicode. In the HTML syntax, attribute names, even those for
530: <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
531: and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123 mike 532: 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 533: 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 534: 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 535:
536: <dd>
537:
538: <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
1.837 mike 539: name</a>. The value is implicitly the empty string.</p>
1.1 mike 540:
541: <div class="example">
542:
543: <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
544: the empty attribute syntax:</p>
545:
546: <pre><input <em>disabled</em>></pre>
547:
548: </div>
549:
550: <p>If an attribute using the empty attribute syntax is to be
551: followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
552: character</a> separating the two.</p>
553:
554: </dd>
555:
1.2 mike 556: <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1 mike 557:
558: <dd>
559:
560: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
561: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
562: characters</a>, followed by a single U+003D EQUALS SIGN
563: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
564: character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
565: addition to the requirements given above for attribute values,
566: must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588 mike 567: characters</a>, any U+0022 QUOTATION MARK characters ("),
568: U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
569: characters (=), U+003C LESS-THAN SIGN characters (<), U+003E
570: GREATER-THAN SIGN characters (>), or U+0060 GRAVE ACCENT
571: characters (`), and must not be the empty string.</p>
1.463 mike 572:
573: <!-- The ` character is in this list on a temporary basis, waiting
574: for IE to fix it's parsing bug whereby it treats ` as an
575: attribute value delimiter. Otherwise, escaping software that
576: tries to be clever and not use quotes when it doesn't need to
577: could be tricked by an attacker.
578:
579: Posit a site that allows the user to input text that is used
580: verbatim in two attributes, such that the user can set the
581: first attribute's value to:
582:
583: `
584:
585: ...and the second to:
586:
587: ` onload='...payload...' end=x
588:
589: ...with the assumption that the site is going to not quote
590: the first one, and quote the second one with double quotes:
591:
592: <body title=` class="` onload='...payload...' end=x">
593:
594: In IE, this is treated as:
595:
596: <body title=' class="'
597: onload='...payload...'
598: end='x"'>
599:
600: -->
601:
1.1 mike 602:
603: <div class="example">
604:
605: <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
606: with the unquoted attribute value syntax:</p>
607:
608: <pre><input <em>value=yes</em>></pre>
609:
610: </div>
611:
612: <p>If an attribute using the unquoted attribute syntax is to be
1.101 mike 613: followed by another attribute or by the optional U+002F SOLIDUS
1.464 mike 614: 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 615: must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
616:
617: </dd>
618:
619: <dt>Single-quoted attribute value syntax</dt>
620:
621: <dd>
622:
623: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
624: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
625: characters</a>, followed by a single U+003D EQUALS SIGN
626: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
627: character">space characters</a>, followed by a single U+0027
1.588 mike 628: APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 629: addition to the requirements given above for attribute values,
1.588 mike 630: must not contain any literal U+0027 APOSTROPHE characters ('), and
631: finally followed by a second single U+0027 APOSTROPHE character
632: (').</p>
1.1 mike 633:
634: <div class="example">
635:
636: <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
637: single-quoted attribute value syntax:</p>
638:
639: <pre><input <em>type='checkbox'</em>></pre>
640:
641: </div>
642:
643: <p>If an attribute using the single-quoted attribute syntax is to
644: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
645: character</a> separating the two.</p>
646:
647: </dd>
648:
649: <dt>Double-quoted attribute value syntax</dt>
650:
651: <dd>
652:
653: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
654: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
655: characters</a>, followed by a single U+003D EQUALS SIGN
656: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
657: character">space characters</a>, followed by a single U+0022
1.588 mike 658: QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 659: addition to the requirements given above for attribute values,
1.588 mike 660: must not contain any literal U+0022 QUOTATION MARK characters ("),
661: and finally followed by a second single U+0022 QUOTATION MARK
662: character (").</p>
1.1 mike 663:
664: <div class="example">
665:
666: <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
667: double-quoted attribute value syntax:</p>
668:
669: <pre><input <em>name="be evil"</em>></pre>
670:
671: </div>
672:
673: <p>If an attribute using the double-quoted attribute syntax is to
674: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
675: character</a> separating the two.</p>
676:
677: </dd>
678:
679: </dl><p>There must never be two or more attributes on the same start tag
680: whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462 mike 681: each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
682: one of the namespaced attributes given by the local name and
683: namespace of the first and second cells of a row from the following
684: table, it must be written using the name given by the third cell
685: from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
1.724 mike 686: </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>
687: </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>
688: </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>
689: </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>
690: </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>
691: </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>
692: </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>
693: </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>
694: </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>
695: </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>
696: </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>
697: </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 698: </td></tr></tbody></table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.755 mike 699: 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 700: is not present; it is implied, but it is still there. An HTML
1.159 mike 701: document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1 mike 702: string <code title=""><html></code> doesn't appear anywhere in
1.159 mike 703: 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
704: 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
705: 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 706: 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
707: element is empty, or if the first thing inside the
1.159 mike 708: <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
709: tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
710: 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
711: 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 712: 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 713: 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 714: <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
1.724 mike 715: tag is present, the parser makes <style> and <script type="text/javascript"> elements
1.1 mike 716: between </head> and <body> end up in the <head> instead of implying
1.159 mike 717: 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
718: 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 719: 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 720: tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
721: immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422 mike 722: 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 723: tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
724: immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123 mike 725: <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 726: tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
727: immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
728: <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123 mike 729: 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 730: tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
731: immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
732: <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 733: <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306 mike 734: <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 735: <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>,
736: <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>,
737: <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>,
738: <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>,
739: <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 740: <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>,
741: element, or if there is no more content in the parent element and
1.123 mike 742: 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 743: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
744: 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 745: 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 746: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
747: 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 748: 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 749: <select>; commented out text below can handle the non-<select> case
1.123 mike 750: 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 751: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
752: <code>select</code> element and--> is immediately followed by
753: another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
754: that are ancestors of the <code>optgroup</code> element, up to and
755: including the first ancestor element that is not an
756: <code>optgroup</code> element, have no more content--> there is no
1.123 mike 757: more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1 mike 758: <select><optgroup></select>
759: <p id=x><optgroup></optgroup>x</p>
760: <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
761: <p><optgroup id=x><optgroup></optgroup>x</p>
762: <p><optgroup><optgroup id=x>x</p>
1.123 mike 763: --><!-- </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 764: tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
765: immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
766: it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123 mike 767: 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 768: first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
769: <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
770: 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 771: 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 772: <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123 mike 773: <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 774: tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
775: 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 776: 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 777: first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
778: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
779: 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
780: <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
781: tag</a> has been omitted. (It can't be omitted if the element is
1.123 mike 782: 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 783: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
784: 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 785: 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 786: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
787: immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123 mike 788: 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 789: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
790: immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123 mike 791: 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 792: tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
793: 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 794: 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 795: tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
796: 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 797: element, or if there is no more content in the parent element.</p><p><strong>However</strong>, a <a href="#syntax-start-tag" title="syntax-start-tag">start
1.755 mike 798: 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 799: 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 800: elements, even though these elements are technically allowed inside
801: <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
802: described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
803: 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 804: 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
805: placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1 mike 806: 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>
807: elements. This does not affect the processing of the element. The
1.304 mike 808: otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381 mike 809: <em>must</em> be included if the element's contents themselves start
810: with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
811: otherwise the leading newline in the contents would be treated like
812: the optional newline, and ignored).</p><div class="example">
1.1 mike 813: <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
814: <pre><pre>Hello</pre></pre>
815: <pre><pre><br>Hello</pre></pre>
1.755 mike 816: </div><h5 id="cdata-rcdata-restrictions"><span class="secno">8.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The text in <a href="#raw-text-elements" title="raw text elements">raw text</a> and
1.373 mike 817: <a href="#rcdata-elements" title="RCDATA elements">RCDATAs</a> element must not
818: contain any occurrences of the string "<code title=""></</code>"
819: (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that
1.1 mike 820: case-insensitively match the tag name of the element followed by one
821: of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM
1.304 mike 822: FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E
1.755 mike 823: GREATER-THAN SIGN (>), or U+002F SOLIDUS (/).</p><h4 id="text"><span class="secno">8.1.3 </span>Text</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-text" title="syntax-text">Text</dfn> is allowed inside elements,
1.1 mike 824: attributes, and comments. Text must consist of Unicode characters.
825: Text must not contain U+0000 characters. Text must not contain
1.316 mike 826: permanently undefined Unicode characters (noncharacters). Text must
827: not contain control characters other than <a href="infrastructure.html#space-character" title="space
828: character">space characters</a>. Extra constraints are placed on
829: what is and what is not allowed in text based on where the text is
1.755 mike 830: 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 831: represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
832: LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.755 mike 833: U+000A LINE FEED (LF) characters in that order.</p><h4 id="character-references"><span class="secno">8.1.4 </span>Character references</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>In certain cases described in other sections, <a href="#syntax-text" title="syntax-text">text</a> may be mixed with <dfn id="syntax-charref" title="syntax-charref">character references</dfn>. These can be used
1.1 mike 834: to escape characters that couldn't otherwise legally be included in
1.588 mike 835: <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
836: (&). Following this, there are three possible kinds of character
837: references:</p><dl><dt>Named character references</dt>
1.1 mike 838:
839: <dd>The ampersand must be followed by one of the names given in the
840: <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677 mike 841: case. <span class="impl">The name must be one that is terminated by
842: a U+003B SEMICOLON character (;).</span></dd>
1.1 mike 843:
844:
845: <dt>Decimal numeric character reference</dt>
846:
847: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 848: character (#), followed by one or more digits in the range U+0030
849: DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
850: integer that corresponds to a Unicode code point that is allowed
851: according to the definition below. The digits must then be followed
852: by a U+003B SEMICOLON character (;).</dd>
1.1 mike 853:
854:
855: <dt>Hexadecimal numeric character reference</dt>
856:
857: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 858: character (#), which must be followed by either a U+0078 LATIN
859: SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
860: character (X), which must then be followed by one or more digits in
861: the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
862: LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
863: LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464 mike 864: representing a base-sixteen integer that corresponds to a Unicode
865: code point that is allowed according to the definition below. The
866: digits must then be followed by a U+003B SEMICOLON character
867: (;).</dd>
1.378 mike 868:
869: </dl><p>The numeric character reference forms described above are allowed
870: to reference any Unicode code point other than U+0000, permanently
871: undefined Unicode characters (noncharacters), and control characters
872: other than <a href="infrastructure.html#space-character" title="space character">space
873: characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464 mike 874: ampersand</dfn> is a U+0026 AMPERSAND character (&) that is
875: followed by some <a href="#syntax-text" title="syntax-text">text</a> other than a
876: <a href="infrastructure.html#space-character">space character</a>, a U+003C LESS-THAN SIGN character
1.755 mike 877: (<), or another U+0026 AMPERSAND character (&).</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 878: the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
879: MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
880: U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
881: LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
882: SQUARE BRACKET (<code title=""><![CDATA[</code>). Following this
883: sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
884: that the text must not contain the three character sequence U+005D
885: RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
886: GREATER-THAN SIGN (<code title="">]]></code>). Finally, the CDATA
887: section must be ended by the three character sequence U+005D RIGHT
888: SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.724 mike 889: SIGN (<code title="">]]></code>).</p><div class="example">
890:
891: <p>CDATA sections can only be used in foreign content (MathML or
892: SVG). In this example, a CDATA section is used to escape the
893: contents of an <code>ms</code> element:</p>
894:
895: <pre><p>You can add a string to a number, but this stringifies the number:</p>
896: <math>
897: <ms><![CDATA[x<y]]></ms>
898: <mo>+</mo>
899: <mn>3</mn>
900: <mo>=</mo>
901: <ms><![CDATA[x<y3]]></ms>
902: </math></pre>
903:
1.755 mike 904: </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 905: four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
906: MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title=""><!--</code>). Following this sequence, the comment may
907: have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
908: restriction that the text must not start with a single U+003E
1.588 mike 909: GREATER-THAN SIGN character (>), nor start with a U+002D
910: HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
911: (>) character, nor contain two consecutive U+002D HYPHEN-MINUS
912: characters (<code title="">--</code>), nor end with a U+002D
913: HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1 mike 914: the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123 mike 915: HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p><div class="impl">
1.1 mike 916:
1.755 mike 917: <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 918:
919: <p><i>This section only applies to user agents, data mining tools,
920: and conformance checkers.</i></p>
921:
922: <p class="note">The rules for parsing XML documents into DOM trees
923: are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
924: syntax</a>".</p>
925:
926: <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
927: rules described in this section to generate the DOM trees. Together,
928: these rules define what is referred to as the <dfn id="html-parser">HTML
929: parser</dfn>.</p>
930:
931: <div class="note">
932:
933: <p>While the HTML syntax described in this specification bears a
934: close resemblance to SGML and XML, it is a separate language with
935: its own parsing rules.</p>
936:
1.183 mike 937: <p>Some earlier versions of HTML (in particular from HTML2 to
938: HTML4) were based on SGML and used SGML parsing rules. However, few
1.1 mike 939: (if any) web browsers ever implemented true SGML parsing for HTML
940: documents; the only user agents to strictly handle HTML as an SGML
941: application have historically been validators. The resulting
942: confusion — with validators claiming documents to have one
943: representation while widely deployed Web browsers interoperably
944: implemented a different representation — has wasted decades
945: of productivity. This version of HTML thus returns to a non-SGML
946: basis.</p>
947:
948: <p>Authors interested in using SGML tools in their authoring
949: pipeline are encouraged to use XML tools and the XML serialization
950: of HTML.</p>
951:
952: </div>
953:
954: <p>This specification defines the parsing rules for HTML documents,
955: whether they are syntactically correct or not. Certain points in the
956: parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
957: errors</dfn>. The error handling for parse errors is well-defined:
958: user agents must either act as described below when encountering
959: such problems, or must abort processing at the first error that they
960: encounter for which they do not wish to apply the rules described
961: below.</p>
962:
963: <p>Conformance checkers must report at least one parse error
964: condition to the user if one or more parse error conditions exist in
965: the document and must not report parse error conditions if none
966: exist in the document. Conformance checkers may report more than one
1.174 mike 967: parse error condition if more than one parse error condition exists
1.1 mike 968: in the document. Conformance checkers are not required to recover
969: from parse errors.</p>
970:
971: <p class="note">Parse errors are only errors with the
972: <em>syntax</em> of HTML. In addition to checking for parse errors,
973: conformance checkers will also verify that the document obeys all
974: the other conformance requirements described in this
975: specification.</p>
976:
977: <p>For the purposes of conformance checkers, if a resource is
978: determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
979: <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
980:
1.266 mike 981: </div><div class="impl">
1.1 mike 982:
1.755 mike 983: <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 984:
985: <p>The input to the HTML parsing process consists of a stream of
986: Unicode characters, which is passed through a
987: <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
1.810 mike 988: construction</a> stage. The output is a <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 989: object.</p>
990:
991: <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
992: support scripting</a> do not have to actually create a DOM
1.810 mike 993: <code><a href="infrastructure.html#document">Document</a></code> object, but the DOM tree in such cases is
1.1 mike 994: still used as the model for the rest of the specification.</p>
995:
996: <p>In the common case, the data handled by the tokenization stage
1.159 mike 997: comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
998: 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 999:
1.724 mike 1000: <p><img alt="" src="http://dev.w3.org/html5/spec/images/parsing-model-overview.png"></p>
1.1 mike 1001:
1002: <p id="nestedParsing">There is only one set of states for the
1003: tokenizer stage and the tree construction stage, but the tree
1004: construction stage is reentrant, meaning that while the tree
1005: construction stage is handling one token, the tokenizer might be
1006: resumed, causing further tokens to be emitted and processed before
1007: the first token's processing is complete.</p>
1008:
1009: <div class="example">
1010:
1011: <p>In the following example, the tree construction stage will be
1012: called upon to handle a "p" start tag token while handling the
1013: "script" start tag token:</p>
1014:
1015: <pre>...
1016: <script>
1017: document.write('<p>');
1018: </script>
1019: ...</pre>
1020:
1021: </div>
1022:
1023: <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
1024: level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
1025: pause flag</dfn>, which must be initially set to false.</p>
1026:
1.266 mike 1027: </div><div class="impl">
1.1 mike 1028:
1.755 mike 1029: <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 1030:
1031: <p>The stream of Unicode characters that comprises the input to the
1032: tokenization stage will be initially seen by the user agent as a
1033: stream of bytes (typically coming over the network or from the local
1034: file system). The bytes encode the actual characters according to a
1035: particular <em>character encoding</em>, which the user agent must
1036: use to decode the bytes into characters.</p>
1037:
1038: <p class="note">For XML documents, the algorithm user agents must
1039: use to determine the character encoding is given by the XML
1.104 mike 1040: specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1 mike 1041:
1042:
1.755 mike 1043: <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 1044:
1045: <p>In some cases, it might be impractical to unambiguously determine
1046: the encoding before parsing the document. Because of this, this
1047: specification provides for a two-pass mechanism with an optional
1048: pre-scan. Implementations are allowed, as described below, to apply
1049: a simplified parsing algorithm to whatever bytes they have available
1050: before beginning to parse the document. Then, the real parser is
1051: started, using a tentative encoding derived from this pre-parse and
1052: other out-of-band metadata. If, while the document is being loaded,
1053: the user agent discovers an encoding declaration that conflicts with
1054: this information, then the parser can get reinvoked to perform a
1055: parse of the document with the real encoding.</p>
1056:
1057: <p id="documentEncoding">User agents must use the following
1058: algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
1059: the character encoding to use when decoding a document in the first
1060: pass. This algorithm takes as input any out-of-band metadata
1061: available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
1062: and all the bytes available so far, and returns an encoding and a
1063: <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
1064: confidence is either <i>tentative</i>, <i>certain</i>, or
1065: <i>irrelevant</i>. The encoding used, and whether the confidence in
1066: that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
1067: determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
1068: encoding is necessary, e.g. because the parser is operating on a
1069: stream of Unicode characters and doesn't have to use an encoding at
1070: all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
1071: <i>irrelevant</i>.</p>
1072:
1073: <ol><li><p>If the transport layer specifies an encoding, and it is
1074: supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1075: <i>certain</i>, and abort these steps.</p></li>
1076:
1077: <li><p>The user agent may wait for more bytes of the resource to be
1078: available, either in this step or at any later step in this
1079: algorithm. For instance, a user agent might wait 500ms or 512
1080: bytes, whichever came first. In general preparsing the source to
1081: find the encoding improves performance, as it reduces the need to
1082: throw away the data structures used when parsing upon finding the
1083: encoding information. However, if the user agent delays too long to
1084: obtain data to determine the encoding, then the cost of the delay
1085: could outweigh any performance improvements from the
1086: preparse.</p></li>
1087:
1088: <li><p>For each of the rows in the following table, starting with
1089: the first one and going down, if there are as many or more bytes
1090: available than the number of bytes in the first column, and the
1091: first bytes of the file match the bytes given in the first column,
1092: then return the encoding given in the cell in the second column of
1093: that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1094: <i>certain</i>, and abort these steps:</p>
1095:
1096: <!-- this table is present in several forms in this file; keep them in sync -->
1097: <table><thead><tr><th>Bytes in Hexadecimal
1098: </th><th>Encoding
1099: </th></tr></thead><tbody><!-- nobody uses this
1100: <tr>
1101: <td>00 00 FE FF
1102: <td>UTF-32BE
1103: <tr>
1104: <td>FF FE 00 00
1105: <td>UTF-32LE
1106: --><tr><td>FE FF
1107: </td><td>UTF-16BE
1108: </td></tr><tr><td>FF FE
1109: </td><td>UTF-16LE
1110: </td></tr><tr><td>EF BB BF
1111: </td><td>UTF-8
1112: <!-- nobody uses this
1113: <tr>
1114: <td>DD 73 66 73
1115: <td>UTF-EBCDIC
1116: -->
1117: </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
1118: (BOMs).</p></li>
1119:
1120: <li><p>Otherwise, the user agent will have to search for explicit
1121: character encoding information in the file itself. This should
1122: proceed as follows:
1123:
1124: </p><p>Let <var title="">position</var> be a pointer to a byte in the
1125: input stream, initially pointing at the first byte. If at any
1126: point during these substeps the user agent either runs out of
1127: bytes or decides that scanning further bytes would not be
1128: efficient, then skip to the next step of the overall character
1129: encoding detection algorithm. User agents may decide that scanning
1130: <em>any</em> bytes is not efficient, in which case these substeps
1131: are entirely skipped.</p>
1132:
1133: <p>Now, repeat the following "two" steps until the algorithm
1134: aborts (either because user agent aborts, as described above, or
1135: because a character encoding is found):</p>
1136:
1137: <ol><li><p>If <var title="">position</var> points to:</p>
1138:
1139: <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '<!--')</dt>
1140: <dd>
1141:
1142: <p>Advance the <var title="">position</var> pointer so that it
1143: points at the first 0x3E byte which is preceded by two 0x2D
1144: bytes (i.e. at the end of an ASCII '-->' sequence) and comes
1145: after the 0x3C byte that was found. (The two 0x2D bytes can be
1146: the same as the those in the '<!--' sequence.)</p>
1147:
1148: </dd>
1149:
1150: <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>
1151: <dd>
1152:
1153: <ol><li><p>Advance the <var title="">position</var> pointer so
1154: that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
1155: 0x2F byte (the one in sequence of characters matched
1156: above).</p></li>
1157:
1158: <li><p><a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get
1159: an attribute</a> and its value. If no attribute was
1160: sniffed, then skip this inner set of steps, and jump to the
1161: second step in the overall "two step" algorithm.</p></li>
1162:
1163: <li><p>If the attribute's name is neither "<code title="">charset</code>" nor "<code title="">content</code>",
1164: then return to step 2 in these inner steps.</p></li>
1165:
1166: <li><p>If the attribute's name is "<code title="">charset</code>", let <var title="">charset</var> be
1167: the attribute's value, interpreted as a character
1168: encoding.</p></li>
1169:
1170: <li><p>Otherwise, the attribute's name is "<code title="">content</code>": apply the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for
1171: extracting an encoding from a Content-Type</a>, giving the
1172: attribute's value as the string to parse. If an encoding is
1173: returned, let <var title="">charset</var> be that
1174: encoding. Otherwise, return to step 2 in these inner
1175: steps.</p></li>
1176:
1177: <li><p>If <var title="">charset</var> is a UTF-16 encoding,
1178: change the value of <var title="">charset</var> to
1179: UTF-8.</p></li>
1180:
1181: <li><p>If <var title="">charset</var> is a supported
1182: character encoding, then return the given encoding, with
1183: <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1184: <i>tentative</i>, and abort all these steps.</p></li>
1185:
1186: <li><p>Otherwise, return to step 2 in these inner
1187: steps.</p></li>
1188:
1189: </ol></dd>
1190:
1.464 mike 1191: <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 1192: <dd>
1193:
1194: <ol><li><p>Advance the <var title="">position</var> pointer so
1195: that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
1196: 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464 mike 1197: (ASCII >) byte.</p></li>
1.1 mike 1198:
1199: <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
1200: attribute</a> until no further attributes can be found,
1201: then jump to the second step in the overall "two step"
1202: algorithm.</p></li>
1203:
1204: </ol></dd>
1205:
1206: <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '<!')</dt>
1207: <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '</')</dt>
1208: <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '<?')</dt>
1209: <dd>
1210:
1211: <p>Advance the <var title="">position</var> pointer so that it
1.464 mike 1212: points at the first 0x3E byte (ASCII >) that comes after the
1.1 mike 1213: 0x3C byte that was found.</p>
1214:
1215: </dd>
1216:
1217: <dt>Any other byte</dt>
1218: <dd>
1219:
1220: <p>Do nothing with that byte.</p>
1221:
1222: </dd>
1223:
1224: </dl></li>
1225:
1226: <li>Move <var title="">position</var> so it points at the next
1227: byte in the input stream, and return to the first step of this
1228: "two step" algorithm.</li>
1229:
1230: </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
1231: attribute</dfn>, it means doing this:</p>
1232:
1233: <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
1234: (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464 mike 1235: 0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1 mike 1236: substep.</p></li>
1237:
1238: <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464 mike 1239: >), then abort the "get an attribute" algorithm. There isn't
1.1 mike 1240: one.</p></li>
1241:
1242: <li><p>Otherwise, the byte at <var title="">position</var> is the
1243: start of the attribute name. Let <var title="">attribute
1244: name</var> and <var title="">attribute value</var> be the empty
1245: string.</p></li>
1246:
1247: <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
1248:
1.464 mike 1249: <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1 mike 1250: name</var> is longer than the empty string</dt>
1251:
1252: <dd>Advance <var title="">position</var> to the next byte and
1253: jump to the step below labeled <i>value</i>.</dd>
1254:
1255: <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1256: FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
1257:
1258: <dd>Jump to the step below labeled <i>spaces</i>.</dd>
1259:
1.464 mike 1260: <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII >)</dt>
1.1 mike 1261:
1262: <dd>Abort the "get an attribute" algorithm. The attribute's
1263: name is the value of <var title="">attribute name</var>, its
1264: value is the empty string.</dd>
1265:
1.464 mike 1266: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1267: Z)</dt>
1.1 mike 1268:
1269: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1270: name</var> (where <var title="">b</var> is the value of the
1271: byte at <var title="">position</var>).</dd>
1272:
1273: <dt>Anything else</dt>
1274:
1275: <dd>Append the Unicode character with the same code point as the
1276: value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
1277: bytes outside the ASCII range are handled here, since only
1278: ASCII characters can contribute to the detection of a character
1279: encoding.)</dd>
1280:
1281: </dl></li>
1282:
1283: <li><p>Advance <var title="">position</var> to the next byte and
1284: return to the previous step.</p></li>
1285:
1286: <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1287: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1288: advance <var title="">position</var> to the next byte, then,
1289: repeat this step.</p></li>
1290:
1291: <li><p>If the byte at <var title="">position</var> is
1.464 mike 1292: <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1 mike 1293: algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
1294: string.</p></li>
1295:
1296: <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464 mike 1297: =) byte.</p></li>
1.1 mike 1298:
1299: <li><p><i>Value:</i> If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1300: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1301: advance <var title="">position</var> to the next byte, then,
1302: repeat this step.</p></li>
1303:
1304: <li><p>Process the byte at <var title="">position</var> as
1305: follows:</p>
1306:
1.464 mike 1307: <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1 mike 1308:
1309: <dd>
1310:
1311: <ol><li>Let <var title="">b</var> be the value of the byte at
1312: <var title="">position</var>.</li>
1313:
1314: <li>Advance <var title="">position</var> to the next
1315: byte.</li>
1316:
1317: <li>If the value of the byte at <var title="">position</var>
1318: is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
1319: an attribute" algorithm. The attribute's name is the value of
1320: <var title="">attribute name</var>, and its value is the
1321: value of <var title="">attribute value</var>.</li>
1322:
1.464 mike 1323: <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
1324: 0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1 mike 1325: than the value of the byte at <var title="">position</var>.</li>
1326:
1327: <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
1328: the value of the byte at <var title="">position</var>.</li>
1329:
1330: <li>Return to the second step in these substeps.</li>
1331:
1332: </ol></dd>
1333:
1.464 mike 1334: <dt>If it is 0x3E (ASCII >)</dt>
1.1 mike 1335:
1336: <dd>Abort the "get an attribute" algorithm. The attribute's
1337: name is the value of <var title="">attribute name</var>, its
1338: value is the empty string.</dd>
1339:
1340:
1.464 mike 1341: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1342: Z)</dt>
1.1 mike 1343:
1344: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1345: value</var> (where <var title="">b</var> is the value of the
1346: byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
1347:
1348: <dt>Anything else</dt>
1349:
1350: <dd>Append the Unicode character with the same code point as the
1351: 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>
1352:
1353: </dl></li>
1354:
1355: <li><p>Process the byte at <var title="">position</var> as
1356: follows:</p>
1357:
1358: <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1359: FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464 mike 1360: >)</dt>
1.1 mike 1361:
1362: <dd>Abort the "get an attribute" algorithm. The attribute's
1363: name is the value of <var title="">attribute name</var> and its
1364: value is the value of <var title="">attribute value</var>.</dd>
1365:
1.464 mike 1366: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1367: Z)</dt>
1.1 mike 1368:
1369: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1370: value</var> (where <var title="">b</var> is the value of the
1371: byte at <var title="">position</var>).</dd>
1372:
1373: <dt>Anything else</dt>
1374:
1375: <dd>Append the Unicode character with the same code point as the
1376: value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
1377:
1378: </dl></li>
1379:
1380: <li><p>Advance <var title="">position</var> to the next byte and
1381: return to the previous step.</p></li>
1382:
1383: </ol><p>For the sake of interoperability, user agents should not use a
1384: pre-scan algorithm that returns different results than the one
1385: described above. (But, if you do, please at least let us know, so
1386: that we can improve this algorithm and benefit everyone...)</p>
1387:
1388: </li>
1389:
1390: <li><p>If the user agent has information on the likely encoding for
1391: this page, e.g. based on the encoding of the page when it was last
1392: visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1393: <i>tentative</i>, and abort these steps.</p></li>
1394:
1.322 mike 1395: <li>
1396:
1397: <p>The user agent may attempt to autodetect the character encoding
1398: from applying frequency analysis or other algorithms to the data
1.568 mike 1399: stream. Such algorithms may use information about the resource
1400: other than the resource's contents, including the address of the
1401: resource. If autodetection succeeds in determining a character
1.322 mike 1402: encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1403: <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
1404:
1405: <p class="note">The UTF-8 encoding has a highly detectable bit
1406: pattern. Documents that contain bytes with values greater than
1407: 0x7F which match the UTF-8 pattern are very likely to be UTF-8,
1408: while documents with byte sequences that do not match it are very
1409: likely not. User-agents are therefore encouraged to search for
1.485 mike 1410: this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322 mike 1411:
1412: </li>
1.1 mike 1413:
1.501 mike 1414: <li>
1415:
1416: <p>Otherwise, return an implementation-defined or user-specified
1417: default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1418: <i>tentative</i>.</p>
1419:
1420: <p>In controlled environments or in environments where the
1421: encoding of documents can be prescribed (for example, for user
1422: agents intended for dedicated use in new networks), the
1423: comprehensive <code title="">UTF-8</code> encoding is
1424: suggested.</p>
1425:
1426: <p>In other environments, the default encoding is typically
1427: dependent on the user's locale (an approximation of the languages,
1.760 mike 1428: and thus often encodings, of the pages that the user is likely to
1429: frequent). The following table gives suggested defaults based on
1430: the user's locale, for compatibility with legacy content. Locales
1431: are identified by BCP 47 language codes. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501 mike 1432:
1433: <!-- based on mozilla 1.9.1 localizations:
1434: http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
1435:
1.504 mike 1436: <table><thead><tr><th>Locale language
1.501 mike 1437: </th><th>Suggested default encoding
1438: </th></tr></thead><tbody><tr><td>ar
1439: </td><td>UTF-8
1440:
1441: </td></tr><tr><td>be
1442: </td><td>ISO-8859-5
1443:
1444: </td></tr><tr><td>bg
1445: </td><td>windows-1251
1446:
1447: </td></tr><tr><td>cs<!-- -CZ -->
1448: </td><td>ISO-8859-2
1449:
1450: </td></tr><tr><td>cy
1451: </td><td>UTF-8
1452:
1453: </td></tr><tr><td>fa<!-- -IR -->
1454: </td><td>UTF-8
1455:
1456: </td></tr><tr><td>he<!-- -IL -->
1457: </td><td>windows-1255
1458:
1459: </td></tr><tr><td>hr
1460: </td><td>UTF-8
1461:
1462: </td></tr><tr><td>hu<!-- -HU -->
1463: </td><td>ISO-8859-2
1464:
1465: </td></tr><tr><td>ja <!-- and ja-JP-mac -->
1466: </td><td>windows-31J <!-- Shift_JIS -->
1467:
1468: </td></tr><tr><td>kk
1469: </td><td>UTF-8
1470:
1471: </td></tr><tr><td>ko<!-- -KR -->
1472: </td><td>windows-949 <!-- EUC-KR -->
1473:
1474: </td></tr><tr><td>ku
1475: </td><td>windows-1254 <!-- ISO-8859-9 -->
1476:
1477: </td></tr><tr><td>lt
1478: </td><td>windows-1257
1479:
1480: </td></tr><tr><td>lv<!-- -LV -->
1481: </td><td>ISO-8859-13
1482:
1483: </td></tr><tr><td>mk<!-- -MK -->
1484: </td><td>UTF-8
1485:
1486: </td></tr><tr><td>or
1487: </td><td>UTF-8
1488:
1489: </td></tr><tr><td>pl<!-- -PL -->
1490: </td><td>ISO-8859-2
1491:
1492: </td></tr><tr><td>ro
1493: </td><td>UTF-8
1494:
1495: </td></tr><tr><td>ru
1496: </td><td>windows-1251
1497:
1498: </td></tr><tr><td>sk
1499: </td><td>windows-1250
1500:
1501: </td></tr><tr><td>sl
1502: </td><td>ISO-8859-2
1503:
1504: </td></tr><tr><td>sr
1505: </td><td>UTF-8
1506:
1507: </td></tr><tr><td>th
1508: </td><td>windows-874 <!-- TIS-620 -->
1509:
1510: </td></tr><tr><td>tr<!-- -TR -->
1511: </td><td>windows-1254 <!-- ISO-8859-9 -->
1512:
1.503 mike 1513: </td></tr><tr><td>uk
1.501 mike 1514: </td><td>windows-1251
1515:
1516: </td></tr><tr><td>vi
1517: </td><td>UTF-8
1518:
1519: </td></tr><tr><td>zh-CN
1520: </td><td>GB18030
1521:
1522: </td></tr><tr><td>zh-TW
1523: </td><td>Big5
1524:
1525: </td></tr><tr><td>All other locales
1526: </td><td>windows-1252
1527:
1528: </td></tr></tbody></table></li>
1.1 mike 1529:
1530: </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
1531: be set to the value returned from this algorithm, at the same time
1532: as the user agent uses the returned value to select the decoder to
1533: use for the input stream.</p>
1534:
1.582 mike 1535: <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
1536: of the HTTP specification, which requires that the encoding be
1537: assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1.647 mike 1538: encoding declaration</a> to the contrary, and of RFC 2046,
1.582 mike 1539: which requires that the encoding be assumed to be US-ASCII in the
1540: absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
1541: contrary. This specification's third approach is motivated by a
1542: desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
1543:
1.1 mike 1544:
1.755 mike 1545: <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 1546:
1.237 mike 1547: <p>User agents must at a minimum support the UTF-8 and Windows-1252
1548: encodings, but may support more.</p>
1549:
1550: <p class="note">It is not unusual for Web browsers to support dozens
1551: if not upwards of a hundred distinct character encodings.</p>
1552:
1.365 mike 1553: <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
1554: every character encoding they support, and should support all the
1555: IANA-registered names and aliases of every character encoding they
1556: support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237 mike 1557:
1558: <p>When comparing a string specifying a character encoding with the
1559: name or alias of a character encoding to determine if they are
1560: 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
1561: then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1562: case-insensitive</a> manner.</p>
1563:
1.539 mike 1564: <hr><p>When a user agent would otherwise use an encoding given in the
1.237 mike 1565: first column of the following table to either convert content to
1566: Unicode characters or convert Unicode characters to bytes, it must
1567: instead use the encoding given in the cell in the second column of
1568: the same row. When a byte or sequence of bytes is treated
1569: differently due to this encoding aliasing, it is said to have been
1570: <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
1571:
1572: <table><caption>Character encoding overrides</caption>
1573: <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
1574: </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
1575: <a href="references.html#refsEUCKR">[EUCKR]</a>
1576: <a href="references.html#refsWIN949">[WIN949]</a>
1577: </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
1578: <a href="references.html#refsRFC1345">[RFC1345]</a>
1579: <a href="references.html#refsGBK">[GBK]</a>
1580: </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
1581: <a href="references.html#refsRFC1345">[RFC1345]</a>
1582: <a href="references.html#refsGBK">[GBK]</a>
1583: </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
1584: <a href="references.html#refsRFC1345">[RFC1345]</a>
1585: <a href="references.html#refsWIN1252">[WIN1252]</a>
1586: </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
1587: <a href="references.html#refsRFC1345">[RFC1345]</a>
1588: <a href="references.html#refsWIN1254">[WIN1254]</a>
1589: </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
1590: <a href="references.html#refsISO885911">[ISO885911]</a>
1591: <a href="references.html#refsWIN874">[WIN874]</a>
1592: </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
1593: <a href="references.html#refsRFC1345">[RFC1345]</a>
1594: <a href="references.html#refsWIN949">[WIN949]</a>
1595: </td></tr><tr><td> Shift_JIS </td><td> windows-31J </td><td>
1596: <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
1597: <a href="references.html#refsWIN31J">[WIN31J]</a>
1598: </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
1599: <a href="references.html#refsTIS620">[TIS620]</a>
1600: <a href="references.html#refsWIN874">[WIN874]</a>
1601: </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
1602: <a href="references.html#refsRFC1345">[RFC1345]</a>
1603: <a href="references.html#refsWIN1252">[WIN1252]</a>
1604: </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
1605: encodings according to the table above is a <a href="introduction.html#willful-violation">willful
1606: violation</a> of the W3C Character Model specification, motivated
1607: by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
1608:
1609: <p>When a user agent is to use the UTF-16 encoding but no BOM has
1610: been found, user agents must default to UTF-16LE.</p>
1611:
1612: <p class="note">The requirement to default UTF-16 to LE rather than
1613: BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581 mike 1614: desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237 mike 1615:
1616: <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
1617: 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>
1618:
1619: <p>Support for encodings based on EBCDIC is not recommended. This
1620: encoding is rarely used for publicly-facing Web content.</p>
1621:
1622: <p>Support for UTF-32 is not recommended. This encoding is rarely
1623: used, and frequently implemented incorrectly.</p>
1624:
1625: <p class="note">This specification does not make any attempt to
1626: support EBCDIC-based encodings and UTF-32 in its algorithms; support
1627: and use of these encodings can thus lead to unexpected behavior in
1628: implementations of this specification.</p>
1629:
1630:
1631:
1.755 mike 1632: <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 1633:
1634: <p>Given an encoding, the bytes in the input stream must be
1635: converted to Unicode characters for the tokenizer, as described by
1636: the rules for that encoding, except that the leading U+FEFF BYTE
1637: ORDER MARK character, if any, must not be stripped by the encoding
1638: layer (it is stripped by the rule below).</p> <!-- this is to
1639: prevent two leading BOMs from being both stripped, once by the
1640: decoder, and once by the parser -->
1641:
1642: <p>Bytes or sequences of bytes in the original byte stream that
1.393 mike 1643: could not be converted to Unicode code points must be converted to
1644: U+FFFD REPLACEMENT CHARACTERs.</p>
1.1 mike 1645:
1646: <p class="note">Bytes or sequences of bytes in the original byte
1647: stream that did not conform to the encoding specification
1648: (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
1649: errors that conformance checkers are expected to report.</p>
1650:
1.438 mike 1651: <p>Any byte or sequence of bytes in the original byte stream that is
1652: <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1 mike 1653: error</a>.</p>
1654:
1655: <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
1656: any are present.</p>
1657:
1.300 mike 1658: <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
1659: character regardless of whether that character was used to determine
1660: the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
1661: motivated by a desire to increase the resilience of user agents in
1662: the face of naïve transcoders.</p>
1663:
1.316 mike 1664: <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315 mike 1665: U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
1666: them to suddenly turn into codepoints when they go through a UTF-16
1667: pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316 mike 1668: CHARACTERs. Any occurrences of such characters and code points are
1669: <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1 mike 1670:
1671: <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
1672: <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
1673: CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315 mike 1674: <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
1675: to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
1676: U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
1677: U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
1678: U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
1679: U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
1680: U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316 mike 1681: errors</a>. These are all control characters or permanently
1682: undefined Unicode characters (noncharacters).</p>
1.1 mike 1683:
1684: <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
1685: characters are treated specially. Any CR characters that are
1686: followed by LF characters must be removed, and any CR characters not
1687: followed by LF characters must be converted to LF characters. Thus,
1688: newlines in HTML DOMs are represented by LF characters, and there
1689: are never any CR characters in the input to the
1690: <a href="#tokenization">tokenization</a> stage.</p>
1691:
1692: <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
1693: input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
1694: the <i><a href="#next-input-character">next input character</a></i> is the first character in the
1695: input. The <dfn id="current-input-character">current input character</dfn> is the last character
1696: to have been <i><a href="#consumed">consumed</a></i>.</p>
1697:
1698: <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
1699: character or just before the end of the input stream) where content
1.159 mike 1700: 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 1701: inserted. The insertion point is relative to the position of the
1702: character immediately after it, it is not an absolute offset into
1703: the input stream. Initially, the insertion point is
1.10 mike 1704: undefined.</p>
1.1 mike 1705:
1706: <p>The "EOF" character in the tables below is a conceptual character
1707: representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159 mike 1708: is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1 mike 1709: <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159 mike 1710: 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 1711: consumed. Otherwise, the "EOF" character is not a real character in
1712: the stream, but rather the lack of any further characters.</p>
1713:
1714:
1.755 mike 1715: <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 1716:
1717: <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
1718: encoding</dfn>, it must run the following steps. This might happen
1719: if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
1720: failed to find an encoding, or if it found an encoding that was not
1721: the actual encoding of the file.</p>
1722:
1723: <ol><li>If the new encoding is identical or equivalent to the encoding
1724: that is already being used to interpret the input stream, then set
1725: the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1726: <i>certain</i> and abort these steps. This happens when the
1727: encoding information found in the file matches what the
1728: <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
1729: encoding, and in the second pass through the parser if the first
1730: pass found that the encoding sniffing algorithm described in the
1731: earlier section failed to find the right encoding.</li>
1732:
1733: <li>If the encoding that is already being used to interpret the
1734: input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1735: <i>certain</i> and abort these steps. The new encoding is ignored;
1736: if it was anything but the same encoding, then it would be clearly
1737: incorrect.</li>
1738:
1739: <li>If the new encoding is a UTF-16 encoding, change it to
1740: UTF-8.</li>
1741:
1742: <li>If all the bytes up to the last byte converted by the current
1743: decoder have the same Unicode interpretations in both the current
1744: encoding and the new encoding, and if the user agent supports
1745: changing the converter on the fly, then the user agent may change
1746: to the new converter for the encoding on the fly. Set the
1747: <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
1748: convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1749: <i>certain</i>, and abort these steps.</li>
1750:
1751: <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
1752: <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
1753: browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
1754: sniffing algorithm</a> and instead just set the encoding to the
1755: new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1756: <i>certain</i>. Whenever possible, this should be done without
1757: actually contacting the network layer (the bytes should be
1758: re-parsed from memory), even if, e.g., the document is marked as
1759: not being cacheable. If this is not possible and contacting the
1760: network layer would involve repeating a request that uses a method
1761: other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
1762: equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1763: <i>certain</i> and ignore the new encoding. The resource will be
1764: misinterpreted. User agents may notify the user of the situation,
1765: to aid in application development.</li>
1766:
1.266 mike 1767: </ol></div><div class="impl">
1768:
1.755 mike 1769: <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 1770:
1.755 mike 1771: <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 1772:
1773: <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
1774: the primary operation of the tree construction stage.</p>
1775:
1776: <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
1777: "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
1778: "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
1779: "<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 1780: "<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 1781: "<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>",
1782: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
1783: "<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
1784: table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
1785: foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
1786: body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
1787: frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
1788: frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
1789: after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
1790: frameset</a>" during the course of the parsing, as described in
1791: the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
1792: how tokens are processed and whether CDATA sections are
1793: supported.</p>
1794:
1795: <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
1796: head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
1797: body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
1798: table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
1799: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
1800: "<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
1801: that the other modes defer to them at various times. When the
1802: algorithm below says that the user agent is to do something
1803: "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
1804: mode", where <var title="">m</var> is one of these modes, the user
1805: agent must use the rules described under the <var title="">m</var>
1806: <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
1807: <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>
1808: to a new value.</p>
1809:
1810: <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540 mike 1811: mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
1812: text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
1813: is also set. This is the insertion mode to which the tree
1814: construction stage will return.</p>
1.1 mike 1815:
1816: <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
1817: mode: in foreign content">in foreign content</a>", the
1818: <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
1819: is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
1820: foreign content">in foreign content</a>" mode to handle HTML
1821: (i.e. not foreign) content.</p>
1822:
1823: <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
1824: mode appropriately</dfn>, it means the UA must follow these
1825: steps:</p>
1826:
1827: <ol><li>Let <var title="">last</var> be false.</li>
1828:
1.604 mike 1829: <li>Let <var title="">foreign</var> be false.</li>
1830:
1.1 mike 1831: <li>Let <var title="">node</var> be the last node in the
1832: <a href="#stack-of-open-elements">stack of open elements</a>.</li>
1833:
1.604 mike 1834: <li><i>Loop</i>: If <var title="">node</var> is the first node in
1835: the stack of open elements, then set <var title="">last</var> to
1836: 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 1837:
1838: <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604 mike 1839: 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
1840: step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1 mike 1841:
1842: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
1843: <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
1844: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.604 mike 1845: mode: in cell">in cell</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1846:
1847: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
1848: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.604 mike 1849: mode: in row">in row</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1850:
1851: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
1852: <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
1853: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.604 mike 1854: table body">in table body</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1855:
1856: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604 mike 1857: 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
1858: the step marked <i title="">end</i>.</li>
1.1 mike 1859:
1860: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
1861: then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column group</a>" and
1.604 mike 1862: jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1863: case</a>)</li>
1.1 mike 1864:
1865: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604 mike 1866: 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
1867: step marked <i title="">end</i>.</li>
1.1 mike 1868:
1.159 mike 1869: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604 mike 1870: 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
1871: the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1872: case</a>)</li> <!-- This is only here for now in case people
1873: think that the spec accidentally omitted it and try to "fix"
1874: it. Note that noscript-in-head is also handled this way. This is
1875: all intentional. The only thing it doesn't handle is the
1876: scripting-disabled fragment parsing case for a <head> element
1877: containing a <noscript> which itself contains something other than
1878: a <link> or a <style> element; you'd expect that to break out of
1879: the <noscript> but it doesn't. This is an edge case that doesn't
1880: affect the spec, since the algorithm for fragment parsing is only
1881: used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
1882: scripting is enabled. -->
1.1 mike 1883:
1.159 mike 1884: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604 mike 1885: 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
1886: step marked <i title="">end</i>.</li>
1.1 mike 1887:
1.5 mike 1888: <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604 mike 1889: 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
1890: the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1891: case</a>)</li>
1.1 mike 1892:
1.159 mike 1893: <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333 mike 1894: then <!--: if the <span><code title="">head</code> element
1895: pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
1896: to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
1897: head</a>"<!--, otherwise, switch the <span>insertion mode</span>
1898: to "<span title="insertion mode: after head">after head</span>".-->
1.604 mike 1899: Then, <!-- in either case, --> jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li> <!-- if the
1900: head element pointer can ever be non-null when we're going through
1901: these steps, we'll need to uncomment out the commented-out bits -->
1902:
1.724 mike 1903: <li>If <var title="">node</var> is an element from the <a href="infrastructure.html#mathml-namespace">MathML
1904: namespace</a> or the <a href="infrastructure.html#svg-namespace">SVG namespace</a>, then set the
1.604 mike 1905: <var title="">foreign</var> flag to true.</li>
1.1 mike 1906:
1907: <li>If <var title="">last</var> is true, then switch the
1908: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.604 mike 1909: body">in body</a>" and jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1 mike 1910:
1911: <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
1912: elements</a>.</li>
1913:
1.604 mike 1914: <li>Return to the step marked <i>loop</i>.</li>
1915:
1916: <li><i>End</i>: If <var title="">foreign</var> is true, switch the
1917: <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
1918: <a href="#insertion-mode">insertion mode</a> is set to, and switch the
1919: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
1920: foreign content">in foreign content</a>".</li>
1.1 mike 1921:
1.755 mike 1922: </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 1923:
1924: <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
1925: stack grows downwards; the topmost node on the stack is the first
1926: one added to the stack, and the bottommost node of the stack is the
1927: most recently added node in the stack (notwithstanding when the
1928: stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
1929:
1930: <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
1931: html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159 mike 1932: <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1 mike 1933: stack.</p>
1934:
1935: <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159 mike 1936: elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1 mike 1937: element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
1938: parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
1939: case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
1940: html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
1941:
1.159 mike 1942: <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 1943: node of the stack. It only gets popped off the stack when the parser
1944: <a href="#stop-parsing" title="stop parsing">finishes</a>.</p>
1.1 mike 1945:
1946: <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
1947: stack.</p>
1948:
1949: <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
1950: element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
1951: 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
1952: open elements</a> (<a href="#fragment-case">fragment case</a>), then the
1953: <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159 mike 1954: of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1 mike 1955:
1956: <p>Elements in the stack fall into the following categories:</p>
1957:
1958: <dl><dt><dfn id="special">Special</dfn></dt>
1959:
1960: <dd><p>The following HTML elements have varying levels of special
1961: 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>,
1962: <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 1963: <code><a href="obsolete.html#basefont">basefont</a></code>, <code><a href="obsolete.html#bgsound">bgsound</a></code>,
1.159 mike 1964: <code><a href="semantics.html#the-blockquote-element">blockquote</a></code>, <code><a href="semantics.html#the-body-element-0">body</a></code>, <code><a href="semantics.html#the-br-element">br</a></code>,
1.5 mike 1965: <code><a href="obsolete.html#center">center</a></code>, <code><a href="tabular-data.html#the-col-element">col</a></code>, <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code>,
1.755 mike 1966: <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID <code>datagrid</code>-->,
1.422 mike 1967: <code><a href="semantics.html#the-dd-element">dd</a></code>, <code><a href="interactive-elements.html#the-details-element">details</a></code>, <code><a href="obsolete.html#dir">dir</a></code>,
1968: <code><a href="semantics.html#the-div-element">div</a></code>, <code><a href="semantics.html#the-dl-element">dl</a></code>, <code><a href="semantics.html#the-dt-element">dt</a></code>,
1.762 mike 1969: <code><a href="text-level-semantics.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-fieldset-element">fieldset</a></code>, <code><a href="semantics.html#the-figure-element">figure</a></code>,
1.422 mike 1970: <code><a href="semantics.html#the-footer-element">footer</a></code>, <code><a href="forms.html#the-form-element">form</a></code>, <code><a href="obsolete.html#frame">frame</a></code>,
1971: <code><a href="obsolete.html#frameset">frameset</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h2</a></code>,
1972: <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h3</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h4</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h5</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code>,
1973: <code><a href="semantics.html#the-head-element-0">head</a></code>, <code><a href="semantics.html#the-header-element">header</a></code>, <code><a href="semantics.html#the-hgroup-element">hgroup</a></code>,
1974: <code><a href="semantics.html#the-hr-element">hr</a></code>, <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>, <!-- <code>image</code>,
1975: (commented out because this isn't an element that can end up on the
1976: stack, so it doesn't matter) --> <code><a href="text-level-semantics.html#the-img-element">img</a></code>,
1977: <code><a href="forms.html#the-input-element">input</a></code>, <code><a href="obsolete.html#isindex-0">isindex</a></code>, <code><a href="semantics.html#the-li-element">li</a></code>,
1978: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="obsolete.html#listing">listing</a></code>, <code><a href="interactive-elements.html#menus">menu</a></code>,
1979: <code><a href="semantics.html#meta">meta</a></code>, <code><a href="semantics.html#the-nav-element">nav</a></code>, <code><a href="obsolete.html#noembed">noembed</a></code>,
1980: <code><a href="obsolete.html#noframes">noframes</a></code>, <code><a href="semantics.html#the-noscript-element">noscript</a></code>, <code><a href="semantics.html#the-ol-element">ol</a></code>,
1981: <code><a href="semantics.html#the-p-element">p</a></code>, <code><a href="text-level-semantics.html#the-param-element">param</a></code>, <code><a href="obsolete.html#plaintext">plaintext</a></code>,
1982: <code><a href="semantics.html#the-pre-element">pre</a></code>, <code><a href="semantics.html#script">script</a></code>, <code><a href="semantics.html#the-section-element">section</a></code>,
1.589 mike 1983: <code><a href="forms.html#the-select-element">select</a></code>, <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
1984: <code><a href="forms.html#the-textarea-element">textarea</a></code>, <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>, <code><a href="tabular-data.html#the-thead-element">thead</a></code>,
1985: <code><a href="semantics.html#the-title-element-0">title</a></code>, <code><a href="tabular-data.html#the-tr-element">tr</a></code>, <code><a href="semantics.html#the-ul-element">ul</a></code>,
1.724 mike 1986: <code><a href="obsolete.html#wbr">wbr</a></code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1 mike 1987:
1988: <dt><dfn id="scoping">Scoping</dfn></dt>
1989: <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
1990: an element in scope">scopes</a> for various parts of the
1.5 mike 1991: parsing: <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="forms.html#the-button-element">button</a></code>,
1.159 mike 1992: <code><a href="tabular-data.html#the-caption-element">caption</a></code>, <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="obsolete.html#the-marquee-element">marquee</a></code>,
1993: <code><a href="text-level-semantics.html#the-object-element">object</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>, <code><a href="tabular-data.html#the-td-element">td</a></code>,
1.1 mike 1994: <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's <code>foreignObject</code>.</p></dd>
1995:
1996: <dt><dfn id="formatting">Formatting</dfn></dt>
1997: <dd><p>The following HTML elements are those that end up in the
1998: <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 1999: <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>,
2000: <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 2001: <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 2002: <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
2003: <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1 mike 2004:
2005: <dt><dfn id="phrasing">Phrasing</dfn></dt>
2006: <dd><p>All other elements found while parsing an HTML
2007: document.</p></dd>
2008:
1.234 mike 2009: </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
2010: specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
2011: match state:</p>
1.1 mike 2012:
2013: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
2014: node</a> (the bottommost node of the stack).</p></li>
2015:
2016: <li><p>If <var title="">node</var> is the target node, terminate in
2017: a match state.</p></li>
2018:
1.234 mike 2019: <li><p>Otherwise, if <var title="">node</var> is one of the element
2020: types in <var title="">list</var>, terminate in a failure
2021: state.</p></li>
1.1 mike 2022:
2023: <li><p>Otherwise, set <var title="">node</var> to the previous
2024: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
2025: 2. (This will never fail, since the loop will always terminate in
2026: the previous step if the top of the stack — an
1.159 mike 2027: <code><a href="semantics.html#the-html-element-0">html</a></code> element — is reached.)</p></li>
1.1 mike 2028:
1.234 mike 2029: </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
2030: it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
2031: of the following element types:</p>
2032:
2033: <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
2034: <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
2035: <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.) -->
2036: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
2037: <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
2038: <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
2039: <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
2040: <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
2041: <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
2042: <li><code title="">foreignObject</code> in the SVG namespace</li>
2043: </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
2044: item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
2045: scope</a> consisting of the following element types:</p>
2046:
2047: <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
2048: in scope</a></i> algorithm.</li>
2049: <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
2050: <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
2051: </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
2052: scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
2053: scope</a> consisting of the following element types:</p>
2054:
2055: <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.) -->
2056: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
2057: </ul><p>Nothing happens if at any time any of the elements in the
1.1 mike 2058: <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
1.810 mike 2059: or removed from, the <code><a href="infrastructure.html#document">Document</a></code> tree. In particular, the
1.1 mike 2060: stack is not changed in this situation. This can cause, amongst
2061: other strange effects, content to be appended to nodes that are no
2062: longer in the DOM.</p>
2063:
2064: <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
2065: the stack is manipulated in a random-access fashion.</p>
2066:
2067:
1.755 mike 2068: <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 2069:
2070: <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
2071: empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
2072:
2073: <p>The list contains elements in the <a href="#formatting">formatting</a>
2074: category, and scope markers. The scope markers are inserted when
1.159 mike 2075: 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 2076: elements, marquees, table cells, and table captions, and are used to
1.5 mike 2077: prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159 mike 2078: elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1 mike 2079: tables.</p>
2080:
2081: <p class="note">The scope markers are unrelated to the concept of an
2082: element being <a href="#has-an-element-in-scope" title="has an element in scope">in
2083: scope</a>.</p>
2084:
2085: <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
2086: elements</a> is associated with the token for which it was
2087: created, so that further elements can be created for that token if
2088: necessary.</p>
2089:
2090: <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
2091: active formatting elements</dfn>, the UA must perform the following
2092: steps:</p>
2093:
2094: <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
2095: elements</a>, then there is nothing to reconstruct; stop this
2096: algorithm.</li>
2097:
2098: <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
2099: active formatting elements</a> is a marker, or if it is an
2100: element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
2101: there is nothing to reconstruct; stop this algorithm.</li>
2102:
2103: <li>Let <var title="">entry</var> be the last (most recently added)
2104: element in the <a href="#list-of-active-formatting-elements">list of active formatting
2105: elements</a>.</li>
2106:
2107: <li>If there are no entries before <var title="">entry</var> in the
2108: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
2109: 8.</li>
2110:
2111: <li>Let <var title="">entry</var> be the entry one earlier than
2112: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2113: elements</a>.</li>
2114:
2115: <li>If <var title="">entry</var> is neither a marker nor an element
2116: that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
2117: 4.</li>
2118:
2119: <li>Let <var title="">entry</var> be the element one later than
2120: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2121: elements</a>.</li>
2122:
2123: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
2124: element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
2125:
2126: <li>Append <var title="">new element</var> to the <a href="#current-node">current
2127: node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
2128: elements</a> so that it is the new <a href="#current-node">current
2129: node</a>.</li>
2130:
2131: <li>Replace the entry for <var title="">entry</var> in the list
2132: with an entry for <var title="">new element</var>.</li>
2133:
2134: <li>If the entry for <var title="">new element</var> in the
2135: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
2136: entry in the list, return to step 7.</li>
2137:
2138: </ol><p>This has the effect of reopening all the formatting elements that
2139: were opened in the current body, cell, or caption (whichever is
2140: youngest) that haven't been explicitly closed.</p>
2141:
2142: <p class="note">The way this specification is written, the
2143: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
2144: elements in chronological order with the least recently added
2145: element first and the most recently added element last (except for
2146: while steps 8 to 11 of the above algorithm are being executed, of
2147: course).</p>
2148:
2149: <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
2150: active formatting elements up to the last marker</dfn>, the UA must
2151: perform the following steps:</p>
2152:
2153: <ol><li>Let <var title="">entry</var> be the last (most recently added)
2154: entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
2155:
2156: <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
2157: formatting elements</a>.</li>
2158:
2159: <li>If <var title="">entry</var> was a marker, then stop the
2160: algorithm at this point. The list has been cleared up to the last
2161: marker.</li>
2162:
2163: <li>Go to step 1.</li>
2164:
1.755 mike 2165: </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 2166:
2167: <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
2168: pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
2169: pointer</dfn> are both null.</p>
2170:
1.159 mike 2171: <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1 mike 2172: implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
2173: element pointer</a> gets set to point to this node.</p>
2174:
2175: <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
2176: points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
2177: whose end tag has not yet been seen. It is used to make form
2178: controls associate with forms in the face of dramatically bad
2179: markup, for historical reasons.</p>
2180:
2181:
1.755 mike 2182: <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 2183:
1.794 mike 2184: <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 2185: <code><a href="infrastructure.html#document">Document</a></code> with which the parser is associated when the
1.1 mike 2186: parser was created, and "disabled" otherwise.</p>
2187:
2188: <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
2189: when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
2190: parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
2191: don't execute in that case.</p>
2192:
2193: <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
2194: created. It is set to "not ok" after certain tokens are seen.</p>
2195:
1.266 mike 2196: </div><div class="impl">
1.1 mike 2197:
1.755 mike 2198: <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 2199:
2200: <p>Implementations must act as if they used the following state
2201: machine to tokenize HTML. The state machine must start in the
2202: <a href="#data-state">data state</a>. Most states consume a single character,
2203: which may have various side-effects, and either switches the state
2204: machine to a new state to <em>reconsume</em> the same character, or
2205: switches it to a new state (to consume the next character), or
2206: repeats the same state (to consume the next character). Some states
2207: have more complicated behavior and can consume several characters
1.541 mike 2208: before switching to another state. In some cases, the tokenizer
2209: state is also changed by the tree construction stage.</p>
1.1 mike 2210:
1.541 mike 2211: <p>The exact behavior of certain states depends on the
2212: <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
2213: elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
2214: buffer</var></dfn> to track progress.</p>
1.1 mike 2215:
2216: <p>The output of the tokenization step is a series of zero or more
2217: of the following tokens: DOCTYPE, start tag, end tag, comment,
2218: character, end-of-file. DOCTYPE tokens have a name, a public
2219: identifier, a system identifier, and a <i>force-quirks
2220: flag</i>. When a DOCTYPE token is created, its name, public
2221: identifier, and system identifier must be marked as missing (which
2222: is a distinct state from the empty string), and the <i>force-quirks
2223: flag</i> must be set to <i>off</i> (its other state is
2224: <i>on</i>). Start and end tag tokens have a tag name, a
2225: <i>self-closing flag</i>, and a list of attributes, each of which
2226: has a name and a value. When a start or end tag token is created,
2227: its <i>self-closing flag</i> must be unset (its other state is that
2228: it be set), and its attributes list must be empty. Comment and
2229: character tokens have data.</p>
2230:
2231: <p>When a token is emitted, it must immediately be handled by the
2232: <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541 mike 2233: can affect the state of the tokenization stage, and can insert
2234: additional characters into the stream. (For example, the
1.1 mike 2235: <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159 mike 2236: using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1 mike 2237: characters into the stream being tokenized.)</p>
2238:
2239: <p>When a start tag token is emitted with its <i>self-closing
2240: flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
2241: self-closing flag">acknowledged</dfn> when it is processed by the
2242: tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
2243:
2244: <p>When an end tag token is emitted with attributes, that is a
2245: <a href="#parse-error">parse error</a>.</p>
2246:
2247: <p>When an end tag token is emitted with its <i>self-closing
2248: flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
2249:
1.541 mike 2250: <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
2251: tag name matches the tag name of the last start tag to have been
2252: emitted from this tokenizer, if any. If no start tag has been
2253: emitted from this tokenizer, then no end tag token is
2254: appropriate.</p>
2255:
1.1 mike 2256: <p>Before each step of the tokenizer, the user agent must first
2257: check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
2258: tokenizer must abort the processing of any nested invocations of the
1.479 mike 2259: tokenizer, yielding control back to the caller.</p>
1.1 mike 2260:
2261: <p>The tokenizer state machine consists of the states defined in the
2262: following subsections.</p>
2263:
1.541 mike 2264:
1.333 mike 2265: <!-- Order of the lists below is supposed to be non-error then
2266: error, by unicode, then EOF, ending with "anything else" -->
1.1 mike 2267:
1.541 mike 2268:
1.755 mike 2269: <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 2270:
2271: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2272:
2273: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.541 mike 2274: <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56 mike 2275: state</a>.</dd>
1.1 mike 2276:
1.541 mike 2277: <dt>U+003C LESS-THAN SIGN (<)</dt>
2278: <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
2279:
2280: <dt>EOF</dt>
2281: <dd>Emit an end-of-file token.</dd>
2282:
2283: <dt>Anything else</dt>
2284: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2285: token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2286:
1.755 mike 2287: </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 2288:
2289: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2290: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2291:
2292: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2293: token.</p>
2294:
2295: <p>Otherwise, emit the character token that was returned.</p>
2296:
2297: <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
2298:
2299:
1.755 mike 2300: <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 2301:
1.541 mike 2302: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2303:
1.541 mike 2304: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.618 mike 2305: <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541 mike 2306: state</a>.</dd>
1.1 mike 2307:
2308: <dt>U+003C LESS-THAN SIGN (<)</dt>
1.541 mike 2309: <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
2310:
2311: <dt>EOF</dt>
2312: <dd>Emit an end-of-file token.</dd>
1.1 mike 2313:
1.541 mike 2314: <dt>Anything else</dt>
2315: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2316: token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 2317:
1.755 mike 2318: </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 2319:
2320: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2321: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2322:
2323: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2324: token.</p>
2325:
2326: <p>Otherwise, emit the character token that was returned.</p>
2327:
2328: <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
2329:
2330:
1.755 mike 2331: <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 2332:
1.541 mike 2333: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2334:
1.541 mike 2335: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2336: <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1 mike 2337:
2338: <dt>EOF</dt>
2339: <dd>Emit an end-of-file token.</dd>
2340:
2341: <dt>Anything else</dt>
1.541 mike 2342: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2343: token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 2344:
1.755 mike 2345: </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 2346:
1.541 mike 2347: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2348:
1.541 mike 2349: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2350: <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1 mike 2351:
1.541 mike 2352: <dt>EOF</dt>
2353: <dd>Emit an end-of-file token.</dd>
1.1 mike 2354:
1.541 mike 2355: <dt>Anything else</dt>
2356: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2357: token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2358:
1.755 mike 2359: </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 2360:
1.541 mike 2361: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2362:
1.541 mike 2363: <dl class="switch"><dt>EOF</dt>
2364: <dd>Emit an end-of-file token.</dd>
1.1 mike 2365:
1.541 mike 2366: <dt>Anything else</dt>
2367: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2368: token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1 mike 2369:
1.755 mike 2370: </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 2371:
1.541 mike 2372: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2373:
1.541 mike 2374: <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
2375: <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1 mike 2376:
1.541 mike 2377: <dt>U+002F SOLIDUS (/)</dt>
1.755 mike 2378: <dd>Switch to the <a href="#end-tag-open-state">end tag open state</a>.</dd>
1.1 mike 2379:
1.541 mike 2380: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2381: <dd>Create a new start tag token, set its tag name to the
2382: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
2383: character's code point), then switch to the <a href="#tag-name-state">tag name
2384: state</a>. (Don't emit the token yet; further details will
2385: be filled in before it is emitted.)</dd>
1.1 mike 2386:
1.541 mike 2387: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2388: <dd>Create a new start tag token, set its tag name to the
2389: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2390: name state</a>. (Don't emit the token yet; further details will
2391: be filled in before it is emitted.)</dd>
1.1 mike 2392:
1.541 mike 2393: <dt>U+003F QUESTION MARK (?)</dt>
2394: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2395: comment state</a>.</dd>
1.1 mike 2396:
1.541 mike 2397: <dt>Anything else</dt>
2398: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2399: character token and reconsume the <a href="#current-input-character">current input
2400: character</a> in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2401:
1.755 mike 2402: </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 2403:
1.541 mike 2404: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2405:
2406: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2407: <dd>Create a new end tag token, set its tag name to the lowercase
1.541 mike 2408: version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
2409: the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1 mike 2410: state</a>. (Don't emit the token yet; further details will be
2411: filled in before it is emitted.)</dd>
2412:
2413: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541 mike 2414: <dd>Create a new end tag token, set its tag name to the
2415: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2416: name state</a>. (Don't emit the token yet; further details will
2417: be filled in before it is emitted.)</dd>
1.1 mike 2418:
2419: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2420: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
2421: state</a>.</dd>
2422:
2423: <dt>EOF</dt>
2424: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2425: character token and a U+002F SOLIDUS character token. Reconsume
2426: the EOF character in the <a href="#data-state">data state</a>.</dd>
2427:
2428: <dt>Anything else</dt>
2429: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2430: comment state</a>.</dd>
2431:
1.755 mike 2432: </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 2433:
2434: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2435:
2436: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2437: <dt>U+000A LINE FEED (LF)</dt>
2438: <dt>U+000C FORM FEED (FF)</dt>
2439: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2440: <dt>U+0020 SPACE</dt>
2441: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
2442:
2443: <dt>U+002F SOLIDUS (/)</dt>
2444: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
2445:
2446: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2447: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
2448: state</a>.</dd>
2449:
2450: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 2451: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2452: character</a> (add 0x0020 to the character's code point) to the
2453: current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
2454: state</a>.</dd>
2455:
2456: <dt>EOF</dt>
2457: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2458: <a href="#data-state">data state</a>.</dd>
2459:
2460: <dt>Anything else</dt>
2461: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2462: tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
2463:
1.755 mike 2464: </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 2465: <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
2466:
2467: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2468:
2469: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2470: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2471: to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
2472:
2473: <dt>Anything else</dt>
2474: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2475: <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
2476: state</a>.</dd>
2477:
1.755 mike 2478: </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 2479: <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
2480:
2481: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2482:
2483: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2484: <dd>Create a new end tag token, and set its tag name to the
2485: lowercase version of the <a href="#current-input-character">current input character</a> (add
2486: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2487: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2488: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2489: the token yet; further details will be filled in before it is
2490: emitted.)</dd>
2491:
2492: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2493: <dd>Create a new end tag token, and set its tag name to the
2494: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2495: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2496: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2497: the token yet; further details will be filled in before it is
2498: emitted.)</dd>
2499:
2500: <dt>Anything else</dt>
2501: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2502: character token, and reconsume the <a href="#current-input-character">current input
2503: character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2504:
1.755 mike 2505: </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 2506: <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
2507:
2508: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2509:
2510: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2511: <dt>U+000A LINE FEED (LF)</dt>
2512: <dt>U+000C FORM FEED (FF)</dt>
2513: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2514: <dt>U+0020 SPACE</dt>
2515: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2516: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2517: state</a>. Otherwise, treat it as per the "anything else" entry
2518: below.</dd>
2519:
2520: <dt>U+002F SOLIDUS (/)</dt>
2521: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2522: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2523: state</a>. Otherwise, treat it as per the "anything else" entry
2524: below.</dd>
2525:
2526: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2527: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2528: token</a>, then emit the current tag token and switch to the
2529: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2530: else" entry below.</dd>
2531:
2532: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2533: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2534: character</a> (add 0x0020 to the character's code point) to the
2535: current tag token's tag name. Append the <a href="#current-input-character">current input
2536: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2537: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2538:
2539: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2540: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2541: tag token's tag name. Append the <a href="#current-input-character">current input
2542: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2543: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2544:
2545: <dt>Anything else</dt>
2546: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2547: character token, a character token for each of the characters in
2548: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2549: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2550: in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2551:
1.755 mike 2552: </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 2553: <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
2554:
2555: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2556:
2557: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2558: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2559: to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
2560:
2561: <dt>Anything else</dt>
2562: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2563: <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
2564: state</a>.</dd>
2565:
1.755 mike 2566: </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 2567: <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
2568:
2569: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2570:
2571: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2572: <dd>Create a new end tag token, and set its tag name to the
2573: lowercase version of the <a href="#current-input-character">current input character</a> (add
2574: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2575: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2576: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2577: the token yet; further details will be filled in before it is
2578: emitted.)</dd>
2579:
2580: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2581: <dd>Create a new end tag token, and set its tag name to the
2582: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2583: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2584: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2585: the token yet; further details will be filled in before it is
2586: emitted.)</dd>
2587:
2588: <dt>Anything else</dt>
2589: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2590: character token, and reconsume the <a href="#current-input-character">current input
2591: character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2592:
1.755 mike 2593: </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 2594: <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
2595:
2596: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2597:
2598: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2599: <dt>U+000A LINE FEED (LF)</dt>
2600: <dt>U+000C FORM FEED (FF)</dt>
2601: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2602: <dt>U+0020 SPACE</dt>
2603: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2604: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2605: state</a>. Otherwise, treat it as per the "anything else" entry
2606: below.</dd>
2607:
2608: <dt>U+002F SOLIDUS (/)</dt>
2609: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2610: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2611: state</a>. Otherwise, treat it as per the "anything else" entry
2612: below.</dd>
2613:
2614: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2615: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2616: token</a>, then emit the current tag token and switch to the
2617: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2618: else" entry below.</dd>
2619:
2620: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2621: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2622: character</a> (add 0x0020 to the character's code point) to the
2623: current tag token's tag name. Append the <a href="#current-input-character">current input
2624: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2625: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2626:
2627: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2628: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2629: tag token's tag name. Append the <a href="#current-input-character">current input
2630: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2631: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2632:
2633: <dt>Anything else</dt>
2634: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2635: character token, a character token for each of the characters in
2636: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2637: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2638: in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2639:
1.755 mike 2640: </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 2641:
2642: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2643:
2644: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2645: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2646: to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
2647:
2648: <dt>U+0021 EXCLAMATION MARK (!)</dt>
2649: <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
2650: EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
2651: escape start state</a>.</dd>
2652:
2653: <dt>Anything else</dt>
2654: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2655: <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
2656: state</a>.</dd>
2657:
1.755 mike 2658: </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 2659: <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
2660:
2661: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2662:
2663: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2664: <dd>Create a new end tag token, and set its tag name to the
2665: lowercase version of the <a href="#current-input-character">current input character</a> (add
2666: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2667: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2668: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2669: the token yet; further details will be filled in before it is
2670: emitted.)</dd>
2671:
2672: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2673: <dd>Create a new end tag token, and set its tag name to the
2674: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2675: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2676: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2677: the token yet; further details will be filled in before it is
2678: emitted.)</dd>
2679:
2680: <dt>Anything else</dt>
2681: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2682: character token, and reconsume the <a href="#current-input-character">current input
2683: character</a> in the <a href="#script-data-state">script data state</a>.</dd>
2684:
1.755 mike 2685: </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 2686: <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
2687:
2688: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2689:
2690: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2691: <dt>U+000A LINE FEED (LF)</dt>
2692: <dt>U+000C FORM FEED (FF)</dt>
2693: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2694: <dt>U+0020 SPACE</dt>
2695: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2696: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2697: state</a>. Otherwise, treat it as per the "anything else" entry
2698: below.</dd>
2699:
2700: <dt>U+002F SOLIDUS (/)</dt>
2701: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2702: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2703: state</a>. Otherwise, treat it as per the "anything else" entry
2704: below.</dd>
2705:
2706: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2707: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2708: token</a>, then emit the current tag token and switch to the
2709: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2710: else" entry below.</dd>
2711:
2712: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2713: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2714: character</a> (add 0x0020 to the character's code point) to the
2715: current tag token's tag name. Append the <a href="#current-input-character">current input
2716: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2717: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2718:
2719: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2720: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2721: tag token's tag name. Append the <a href="#current-input-character">current input
2722: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2723: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2724:
2725: <dt>Anything else</dt>
2726: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2727: character token, a character token for each of the characters in
2728: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2729: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2730: in the <a href="#script-data-state">script data state</a>.</dd>
2731:
1.755 mike 2732: </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 2733:
2734: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2735:
2736: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2737: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2738: <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
2739:
2740: <dt>Anything else</dt>
2741: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2742: <a href="#script-data-state">script data state</a>.</dd>
2743:
1.755 mike 2744: </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 2745:
2746: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2747:
2748: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2749: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2750: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2751:
2752: <dt>Anything else</dt>
2753: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2754: <a href="#script-data-state">script data state</a>.</dd>
2755:
1.755 mike 2756: </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 2757:
2758: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2759:
2760: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2761: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2762: <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
2763:
1.542 mike 2764: <dt>U+003C LESS-THAN SIGN (<)</dt>
2765: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2766: state</a>.</p></dd>
2767:
1.541 mike 2768: <dt>EOF</dt>
2769: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2770: <a href="#data-state">data state</a>.</dd>
2771:
2772: <dt>Anything else</dt>
1.542 mike 2773: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2774: token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2775:
1.755 mike 2776: </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 2777:
2778: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2779:
2780: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2781: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2782: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2783:
1.542 mike 2784: <dt>U+003C LESS-THAN SIGN (<)</dt>
2785: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2786: state</a>.</p></dd>
2787:
1.541 mike 2788: <dt>EOF</dt>
2789: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2790: <a href="#data-state">data state</a>.</dd>
2791:
2792: <dt>Anything else</dt>
1.542 mike 2793: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2794: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2795:
1.755 mike 2796: </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 2797:
2798: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2799:
2800: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2801: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
2802: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2803:
1.542 mike 2804: <dt>U+003C LESS-THAN SIGN (<)</dt>
2805: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2806: state</a>.</p></dd>
2807:
1.541 mike 2808: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2809: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
2810: <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2811:
2812: <dt>EOF</dt>
2813: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2814: <a href="#data-state">data state</a>.</dd>
2815:
2816: <dt>Anything else</dt>
1.542 mike 2817: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2818: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2819:
1.755 mike 2820: </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 2821:
2822: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2823:
2824: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2825: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2826: to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
2827:
2828: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2829: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2830: <a href="#current-input-character">current input character</a> as a character token. Set the
2831: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2832: lowercase version of the <a href="#current-input-character">current input character</a> (add
2833: 0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
2834: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2835: state</a>.</dd>
2836:
2837: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2838: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2839: <a href="#current-input-character">current input character</a> as a character token. Set the
2840: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2841: <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
2842: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2843: state</a>.</dd>
2844:
2845: <dt>Anything else</dt>
2846: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2847: <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
2848: escaped state</a>.</dd>
2849:
1.755 mike 2850: </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 2851:
2852: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2853:
2854: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2855: <dd>Create a new end tag token, and set its tag name to the
2856: lowercase version of the <a href="#current-input-character">current input character</a> (add
2857: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2858: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2859: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2860: state</a>. (Don't emit the token yet; further details will be
2861: filled in before it is emitted.)</dd>
2862:
2863: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2864: <dd>Create a new end tag token, and set its tag name to the
2865: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2866: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2867: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2868: state</a>. (Don't emit the token yet; further details will be
2869: filled in before it is emitted.)</dd>
2870:
2871: <dt>Anything else</dt>
2872: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2873: character token, and reconsume the <a href="#current-input-character">current input
2874: character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2875:
1.755 mike 2876: </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 2877:
2878: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2879:
2880: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2881: <dt>U+000A LINE FEED (LF)</dt>
2882: <dt>U+000C FORM FEED (FF)</dt>
2883: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2884: <dt>U+0020 SPACE</dt>
2885: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2886: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2887: state</a>. Otherwise, treat it as per the "anything else" entry
2888: below.</dd>
2889:
2890: <dt>U+002F SOLIDUS (/)</dt>
2891: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2892: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2893: state</a>. Otherwise, treat it as per the "anything else" entry
2894: below.</dd>
2895:
2896: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2897: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2898: token</a>, then emit the current tag token and switch to the
2899: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2900: else" entry below.</dd>
2901:
2902: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2903: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2904: character</a> (add 0x0020 to the character's code point) to the
2905: current tag token's tag name. Append the <a href="#current-input-character">current input
2906: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2907: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2908:
2909: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2910: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2911: tag token's tag name. Append the <a href="#current-input-character">current input
2912: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2913: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2914:
2915: <dt>Anything else</dt>
2916: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2917: character token, a character token for each of the characters in
2918: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2919: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2920: in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2921:
1.755 mike 2922: </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 2923:
2924: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2925:
2926: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2927: <dt>U+000A LINE FEED (LF)</dt>
2928: <dt>U+000C FORM FEED (FF)</dt>
2929: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2930: <dt>U+0020 SPACE</dt>
2931: <dt>U+002F SOLIDUS (/)</dt>
2932: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2933: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2934: 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
2935: double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
2936: data escaped state</a>.</dd>
2937:
2938: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2939: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2940: token. Append the lowercase version of the <a href="#current-input-character">current input
2941: character</a> (add 0x0020 to the character's code point) to the
2942: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
2943: escape start state</a>.</dd>
2944:
2945: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2946: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2947: token. Append the <a href="#current-input-character">current input character</a> to the
2948: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
2949: escape start state</a>.</dd>
2950:
2951: <dt>Anything else</dt>
2952: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2953: <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2954:
1.755 mike 2955: </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 2956:
2957: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2958:
2959: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2960: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2961: <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
2962:
2963: <dt>U+003C LESS-THAN SIGN (<)</dt>
2964: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2965: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2966: state</a>.</p></dd>
2967:
2968: <dt>EOF</dt>
2969: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2970: <a href="#data-state">data state</a>.</dd>
2971:
2972: <dt>Anything else</dt>
2973: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2974: token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
2975: state</a>.</dd>
2976:
1.755 mike 2977: </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 2978:
2979: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2980:
2981: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2982: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2983: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
2984:
2985: <dt>U+003C LESS-THAN SIGN (<)</dt>
2986: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2987: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2988: state</a>.</p></dd>
2989:
2990: <dt>EOF</dt>
2991: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2992: <a href="#data-state">data state</a>.</dd>
2993:
2994: <dt>Anything else</dt>
2995: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2996: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
2997: state</a>.</dd>
2998:
1.755 mike 2999: </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 3000:
3001: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3002:
3003: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3004: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
3005: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
3006:
3007: <dt>U+003C LESS-THAN SIGN (<)</dt>
3008: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
3009: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
3010: state</a>.</p></dd>
3011:
3012: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3013: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
3014: <a href="#script-data-state">script data state</a>.</dd>
3015:
3016: <dt>EOF</dt>
3017: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3018: <a href="#data-state">data state</a>.</dd>
3019:
3020: <dt>Anything else</dt>
3021: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3022: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
3023: state</a>.</dd>
3024:
1.755 mike 3025: </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 3026:
3027: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3028:
3029: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
3030: <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
3031: buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
3032: double escape end state</a>.</dd>
3033:
3034: <dt>Anything else</dt>
3035: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3036: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
3037:
1.755 mike 3038: </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 3039:
3040: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3041:
3042: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3043: <dt>U+000A LINE FEED (LF)</dt>
3044: <dt>U+000C FORM FEED (FF)</dt>
3045: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3046: <dt>U+0020 SPACE</dt>
3047: <dt>U+002F SOLIDUS (/)</dt>
3048: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3049: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3050: 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
3051: escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
3052: double escaped state</a>.</dd>
3053:
3054: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3055: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3056: token. Append the lowercase version of the <a href="#current-input-character">current input
3057: character</a> (add 0x0020 to the character's code point) to the
3058: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
3059: escape end state</a>.</dd>
3060:
3061: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
3062: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3063: token. Append the <a href="#current-input-character">current input character</a> to the
3064: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
3065: escape end state</a>.</dd>
3066:
3067: <dt>Anything else</dt>
3068: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3069: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1 mike 3070:
1.755 mike 3071: </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 3072:
3073: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3074:
3075: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3076: <dt>U+000A LINE FEED (LF)</dt>
3077: <dt>U+000C FORM FEED (FF)</dt>
3078: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3079: <dt>U+0020 SPACE</dt>
3080: <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3081:
3082: <dt>U+002F SOLIDUS (/)</dt>
3083: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3084:
3085: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3086: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3087: state</a>.</dd>
3088:
3089: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3090: <dd>Start a new attribute in the current tag token. Set that
3091: attribute's name to the lowercase version of the <a href="#current-input-character">current input
3092: character</a> (add 0x0020 to the character's code point), and its
3093: value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
3094: state</a>.</dd>
3095:
3096: <dt>U+0022 QUOTATION MARK (")</dt>
3097: <dt>U+0027 APOSTROPHE (')</dt>
3098: <dt>U+003C LESS-THAN SIGN (<)</dt>
3099: <dt>U+003D EQUALS SIGN (=)</dt>
3100: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3101: entry below.</dd>
3102:
3103: <dt>EOF</dt>
3104: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3105: <a href="#data-state">data state</a>.</dd>
3106:
3107: <dt>Anything else</dt>
3108: <dd>Start a new attribute in the current tag token. Set that
3109: attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
3110: the empty string. Switch to the <a href="#attribute-name-state">attribute name
3111: state</a>.</dd>
3112:
1.755 mike 3113: </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 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: <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3123:
3124: <dt>U+002F SOLIDUS (/)</dt>
3125: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3126:
3127: <dt>U+003D EQUALS SIGN (=)</dt>
3128: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3129:
3130: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3131: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3132: state</a>.</dd>
3133:
3134: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3135: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3136: character</a> (add 0x0020 to the character's code point) to the
3137: current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1 mike 3138: state</a>.</dd>
3139:
3140: <dt>U+0022 QUOTATION MARK (")</dt>
3141: <dt>U+0027 APOSTROPHE (')</dt>
3142: <dt>U+003C LESS-THAN SIGN (<)</dt>
3143: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3144: entry below.</dd>
3145:
3146: <dt>EOF</dt>
3147: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3148: <a href="#data-state">data state</a>.</dd>
3149:
3150: <dt>Anything else</dt>
1.541 mike 3151: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3152: attribute's name. Stay in the <a href="#attribute-name-state">attribute name
3153: state</a>.</dd>
1.1 mike 3154:
3155: </dl><p>When the user agent leaves the attribute name state (and before
3156: emitting the tag token, if appropriate), the complete attribute's
3157: name must be compared to the other attributes on the same token;
3158: if there is already an attribute on the token with the exact same
3159: name, then this is a <a href="#parse-error">parse error</a> and the new
3160: attribute must be dropped, along with the value that gets
3161: associated with it (if any).</p>
3162:
3163:
1.755 mike 3164: <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 3165:
3166: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3167:
3168: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3169: <dt>U+000A LINE FEED (LF)</dt>
3170: <dt>U+000C FORM FEED (FF)</dt>
3171: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3172: <dt>U+0020 SPACE</dt>
3173: <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3174:
3175: <dt>U+002F SOLIDUS (/)</dt>
3176: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3177:
3178: <dt>U+003D EQUALS SIGN (=)</dt>
3179: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3180:
3181: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3182: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3183: state</a>.</dd>
3184:
3185: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3186: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3187: attribute's name to the lowercase version of the <a href="#current-input-character">current
3188: input character</a> (add 0x0020 to the character's code point),
3189: and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
3190: name state</a>.</dd>
1.1 mike 3191:
3192: <dt>U+0022 QUOTATION MARK (")</dt>
3193: <dt>U+0027 APOSTROPHE (')</dt>
3194: <dt>U+003C LESS-THAN SIGN (<)</dt>
3195: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3196: entry below.</dd>
3197:
3198: <dt>EOF</dt>
3199: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3200: <a href="#data-state">data state</a>.</dd>
3201:
3202: <dt>Anything else</dt>
3203: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3204: attribute's name to the <a href="#current-input-character">current input character</a>, and
3205: its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1 mike 3206: state</a>.</dd>
3207:
1.755 mike 3208: </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 3209:
3210: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3211:
3212: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3213: <dt>U+000A LINE FEED (LF)</dt>
3214: <dt>U+000C FORM FEED (FF)</dt>
3215: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3216: <dt>U+0020 SPACE</dt>
3217: <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3218:
3219: <dt>U+0022 QUOTATION MARK (")</dt>
3220: <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
3221:
3222: <dt>U+0026 AMPERSAND (&)</dt>
3223: <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541 mike 3224: and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1 mike 3225:
3226: <dt>U+0027 APOSTROPHE (')</dt>
3227: <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
3228:
3229: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3230: <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
3231: the <a href="#data-state">data state</a>.</dd>
3232:
3233: <dt>U+003C LESS-THAN SIGN (<)</dt>
3234: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3235: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3236: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3237: entry below.</dd>
3238:
3239: <dt>EOF</dt>
3240: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3241: <a href="#data-state">data state</a>.</dd>
3242:
3243: <dt>Anything else</dt>
3244: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3245: attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
3246: state</a>.</dd>
3247:
1.755 mike 3248: </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 3249:
3250: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3251:
3252: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3253: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3254: state</a>.</dd>
3255:
3256: <dt>U+0026 AMPERSAND (&)</dt>
3257: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3258: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3259: being U+0022 QUOTATION MARK (").</dd>
3260:
3261: <dt>EOF</dt>
3262: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3263: <a href="#data-state">data state</a>.</dd>
3264:
3265: <dt>Anything else</dt>
1.541 mike 3266: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3267: attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
3268: (double-quoted) state</a>.</dd>
1.1 mike 3269:
1.755 mike 3270: </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 3271:
3272: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3273:
3274: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3275: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3276: state</a>.</dd>
3277:
3278: <dt>U+0026 AMPERSAND (&)</dt>
3279: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3280: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3281: being U+0027 APOSTROPHE (').</dd>
3282:
3283: <dt>EOF</dt>
3284: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3285: <a href="#data-state">data state</a>.</dd>
3286:
3287: <dt>Anything else</dt>
1.541 mike 3288: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3289: attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
3290: (single-quoted) state</a>.</dd>
1.1 mike 3291:
1.755 mike 3292: </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 3293:
3294: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3295:
3296: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3297: <dt>U+000A LINE FEED (LF)</dt>
3298: <dt>U+000C FORM FEED (FF)</dt>
3299: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3300: <dt>U+0020 SPACE</dt>
3301: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3302:
3303: <dt>U+0026 AMPERSAND (&)</dt>
3304: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299 mike 3305: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3306: being U+003E GREATER-THAN SIGN (>).</dd>
1.1 mike 3307:
3308: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3309: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3310: state</a>.</dd>
3311:
3312: <dt>U+0022 QUOTATION MARK (")</dt>
3313: <dt>U+0027 APOSTROPHE (')</dt>
3314: <dt>U+003C LESS-THAN SIGN (<)</dt>
3315: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3316: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3317: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3318: entry below.</dd>
3319:
3320: <dt>EOF</dt>
3321: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3322: <a href="#data-state">data state</a>.</dd>
3323:
3324: <dt>Anything else</dt>
1.541 mike 3325: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3326: attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1 mike 3327: state</a>.</dd>
3328:
1.755 mike 3329: </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 3330:
3331: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
3332:
3333: <p>If nothing is returned, append a U+0026 AMPERSAND character to
3334: the current attribute's value.</p>
3335:
3336: <p>Otherwise, append the returned character token to the current
3337: attribute's value.</p>
3338:
3339: <p>Finally, switch back to the attribute value state that you were
3340: in when were switched into this state.</p>
3341:
3342:
1.755 mike 3343: <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 3344:
3345: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3346:
3347: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3348: <dt>U+000A LINE FEED (LF)</dt>
3349: <dt>U+000C FORM FEED (FF)</dt>
3350: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3351: <dt>U+0020 SPACE</dt>
3352: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3353:
3354: <dt>U+002F SOLIDUS (/)</dt>
3355: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3356:
3357: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3358: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3359: state</a>.</dd>
3360:
3361: <dt>EOF</dt>
3362: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3363: <a href="#data-state">data state</a>.</dd>
3364:
3365: <dt>Anything else</dt>
3366: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3367: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3368:
1.755 mike 3369: </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 3370:
3371: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3372:
3373: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3374: <dd>Set the <i>self-closing flag</i> of the current tag
3375: token. Emit the current tag token. Switch to the <a href="#data-state">data
3376: state</a>.</dd>
3377:
3378: <dt>EOF</dt>
3379: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3380: <a href="#data-state">data state</a>.</dd>
3381:
3382: <dt>Anything else</dt>
3383: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3384: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3385:
1.755 mike 3386: </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 3387:
3388: <p>Consume every character up to and including the first U+003E
3389: GREATER-THAN SIGN character (>) or the end of the file (EOF),
3390: whichever comes first. Emit a comment token whose data is the
3391: concatenation of all the characters starting from and including
3392: the character that caused the state machine to switch into the
3393: bogus comment state, up to and including the character immediately
3394: before the last consumed character (i.e. up to the character just
3395: before the U+003E or EOF character). (If the comment was started
3396: by the end of the file (EOF), the token is empty.)</p>
3397:
3398: <p>Switch to the <a href="#data-state">data state</a>.</p>
3399:
3400: <p>If the end of the file was reached, reconsume the EOF
3401: character.</p>
3402:
3403:
1.755 mike 3404: <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 3405:
1.588 mike 3406: <p>If the next two characters are both U+002D HYPHEN-MINUS
3407: characters (-), consume those two characters, create a comment token
1.1 mike 3408: whose data is the empty string, and switch to the <a href="#comment-start-state">comment
3409: start state</a>.</p>
3410:
3411: <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3412: case-insensitive</a> match for the word "DOCTYPE", then consume
3413: those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
3414:
3415: <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
3416: content</a>" and the <a href="#current-node">current node</a> is not an element
1.724 mike 3417: in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585 mike 3418: an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
3419: five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
3420: character before and after), then consume those characters and
3421: switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1 mike 3422:
3423: <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
3424: <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
3425: consumed, if any, is the first character that will be in the
3426: comment.</p>
3427:
3428:
1.755 mike 3429: <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 3430:
3431: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3432:
3433: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3434: <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
3435:
3436: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3437: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
3438: <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
3439: -->
3440:
3441: <dt>EOF</dt>
3442: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3443: the EOF character in the <a href="#data-state">data state</a>.</dd>
3444:
3445: <dt>Anything else</dt>
1.541 mike 3446: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3447: token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3448:
1.755 mike 3449: </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 3450:
3451: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3452:
3453: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3454: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3455:
3456: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3457: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
3458: the <a href="#data-state">data state</a>.</dd>
3459:
3460: <dt>EOF</dt>
3461: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3462: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3463: in comment end state -->
3464:
3465: <dt>Anything else</dt>
1.541 mike 3466: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3467: <a href="#current-input-character">current input character</a> to the comment token's
3468: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3469:
1.755 mike 3470: </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 3471:
3472: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3473:
3474: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3475: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
3476:
3477: <dt>EOF</dt>
3478: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3479: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3480: in comment end state -->
3481:
3482: <dt>Anything else</dt>
1.541 mike 3483: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3484: token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3485:
1.755 mike 3486: </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 3487:
3488: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3489:
3490: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3491: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3492:
3493: <dt>EOF</dt>
3494: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3495: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3496: in comment end state -->
3497:
3498: <dt>Anything else</dt>
1.541 mike 3499: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3500: <a href="#current-input-character">current input character</a> to the comment token's
3501: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3502:
1.755 mike 3503: </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 3504:
3505: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3506:
3507: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3508: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3509: state</a>.</dd>
3510:
3511: <dt>U+0009 CHARACTER TABULATION</dt>
3512: <dt>U+000A LINE FEED (LF)</dt>
3513: <dt>U+000C FORM FEED (FF)</dt>
3514: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3515: <dt>U+0020 SPACE</dt>
1.588 mike 3516: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3517: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3518: comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
3519: state</a>.</dd>
1.1 mike 3520:
3521: <dt>U+0021 EXCLAMATION MARK (!)</dt>
3522: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
3523: state</a>.</dd>
3524:
1.333 mike 3525: <dt>U+002D HYPHEN-MINUS (-)</dt>
3526: <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464 mike 3527: character (-) to the comment token's data. Stay in the
1.333 mike 3528: <a href="#comment-end-state">comment end state</a>.</dd>
3529:
1.1 mike 3530: <dt>EOF</dt>
3531: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3532: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
1.724 mike 3533: security reasons: otherwise, hostile user could put a <script type="text/javascript"> in
1.1 mike 3534: a comment e.g. in a blog comment and then DOS the server so that
1.724 mike 3535: the end tag isn't read, and then the commented <script type="text/javascript"> tag would
1.1 mike 3536: be treated as live code -->
3537:
3538: <dt>Anything else</dt>
1.588 mike 3539: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3540: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3541: comment token's data. Switch to the <a href="#comment-state">comment
3542: state</a>.</dd>
1.1 mike 3543:
1.755 mike 3544: </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 3545:
3546: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3547:
1.333 mike 3548: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588 mike 3549: <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464 mike 3550: EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1 mike 3551: to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3552:
1.333 mike 3553: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3554: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3555: state</a>.</dd>
3556:
1.1 mike 3557: <dt>EOF</dt>
3558: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3559: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3560: comment in comment end state -->
3561:
3562: <dt>Anything else</dt>
1.588 mike 3563: <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541 mike 3564: EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
3565: character</a> to the comment token's data. Switch to the
3566: <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3567:
1.755 mike 3568: </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 3569:
3570: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3571:
1.333 mike 3572: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1 mike 3573: <dt>U+000A LINE FEED (LF)</dt>
3574: <dt>U+000C FORM FEED (FF)</dt>
3575: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3576: <dt>U+0020 SPACE</dt>
1.541 mike 3577: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1 mike 3578: the <a href="#comment-end-space-state">comment end space state</a>.</dd>
3579:
1.333 mike 3580: <dt>U+002D HYPHEN-MINUS (-)</dt>
3581: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3582:
3583: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3584: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3585: state</a>.</dd>
3586:
1.1 mike 3587: <dt>EOF</dt>
3588: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3589: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3590: comment in comment end state -->
3591:
3592: <dt>Anything else</dt>
1.541 mike 3593: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1 mike 3594: to the <a href="#comment-state">comment state</a>.</dd>
3595:
1.755 mike 3596: </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 3597:
3598: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3599:
3600: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3601: <dt>U+000A LINE FEED (LF)</dt>
3602: <dt>U+000C FORM FEED (FF)</dt>
3603: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3604: <dt>U+0020 SPACE</dt>
3605: <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3606:
3607: <dt>EOF</dt>
3608: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3609: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3610: the EOF character in the <a href="#data-state">data state</a>.</dd>
3611:
3612: <dt>Anything else</dt>
1.608 mike 3613: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
3614: <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1 mike 3615:
1.755 mike 3616: </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 3617:
3618: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3619:
3620: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3621: <dt>U+000A LINE FEED (LF)</dt>
3622: <dt>U+000C FORM FEED (FF)</dt>
3623: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3624: <dt>U+0020 SPACE</dt>
3625: <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3626:
3627: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3628: <dd>Create a new DOCTYPE token. Set the token's name to the
1.541 mike 3629: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1 mike 3630: character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
3631: state</a>.</dd>
3632:
1.333 mike 3633: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3634: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3635: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
3636: the <a href="#data-state">data state</a>.</dd>
3637:
1.1 mike 3638: <dt>EOF</dt>
3639: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3640: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3641: the EOF character in the <a href="#data-state">data state</a>.</dd>
3642:
3643: <dt>Anything else</dt>
3644: <dd>Create a new DOCTYPE token. Set the token's name to the
3645: <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
3646: state</a>.</dd>
3647:
1.755 mike 3648: </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 3649:
3650: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3651:
3652: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3653: <dt>U+000A LINE FEED (LF)</dt>
3654: <dt>U+000C FORM FEED (FF)</dt>
3655: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3656: <dt>U+0020 SPACE</dt>
3657: <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3658:
3659: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3660: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3661: state</a>.</dd>
3662:
3663: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3664: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3665: character</a> (add 0x0020 to the character's code point) to the
3666: current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3667: state</a>.</dd>
1.1 mike 3668:
3669: <dt>EOF</dt>
3670: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3671: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3672: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3673:
3674: <dt>Anything else</dt>
1.541 mike 3675: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3676: DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3677: state</a>.</dd>
1.1 mike 3678:
1.755 mike 3679: </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 3680:
3681: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3682:
3683: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3684: <dt>U+000A LINE FEED (LF)</dt>
3685: <dt>U+000C FORM FEED (FF)</dt>
3686: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3687: <dt>U+0020 SPACE</dt>
3688: <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3689:
3690: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3691: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3692: state</a>.</dd>
3693:
3694: <dt>EOF</dt>
3695: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3696: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3697: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3698:
3699: <dt>Anything else</dt>
3700: <dd>
3701:
3702: <p>If the six characters starting from the <a href="#current-input-character">current input
3703: character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
3704: for the word "PUBLIC", then consume those characters and switch to
1.444 mike 3705: the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1 mike 3706:
3707: <p>Otherwise, if the six characters starting from the
3708: <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3709: case-insensitive</a> match for the word "SYSTEM", then consume
1.444 mike 3710: those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
3711: keyword state</a>.</p>
1.1 mike 3712:
3713: <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
3714: DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
3715: the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
3716:
3717: </dd>
3718:
1.755 mike 3719: </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 3720:
3721: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3722:
3723: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3724: <dt>U+000A LINE FEED (LF)</dt>
3725: <dt>U+000C FORM FEED (FF)</dt>
3726: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3727: <dt>U+0020 SPACE</dt>
3728: <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
3729: state</a>.</dd>
3730:
1.620 mike 3731: <dt>U+0022 QUOTATION MARK (")</dt>
3732: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3733: identifier to the empty string (not missing), then switch to the
3734: <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
3735:
3736: <dt>U+0027 APOSTROPHE (')</dt>
3737: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3738: identifier to the empty string (not missing), then switch to the
3739: <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
3740:
3741: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3742: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3743: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3744: token. Switch to the <a href="#data-state">data state</a>.</dd>
3745:
1.444 mike 3746: <dt>EOF</dt>
3747: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3748: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3749: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3750:
3751: <dt>Anything else</dt>
1.620 mike 3752: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3753: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3754: DOCTYPE state</a>.</dd>
1.444 mike 3755:
1.755 mike 3756: </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 3757:
3758: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3759:
3760: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3761: <dt>U+000A LINE FEED (LF)</dt>
3762: <dt>U+000C FORM FEED (FF)</dt>
3763: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3764: <dt>U+0020 SPACE</dt>
3765: <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
3766:
3767: <dt>U+0022 QUOTATION MARK (")</dt>
3768: <dd>Set the DOCTYPE token's public identifier to the empty string
3769: (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
3770: (double-quoted) state</a>.</dd>
3771:
3772: <dt>U+0027 APOSTROPHE (')</dt>
3773: <dd>Set the DOCTYPE token's public identifier to the empty string
3774: (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
3775: (single-quoted) state</a>.</dd>
3776:
3777: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3778: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3779: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3780: token. Switch to the <a href="#data-state">data state</a>.</dd>
3781:
3782: <dt>EOF</dt>
3783: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3784: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3785: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3786:
3787: <dt>Anything else</dt>
3788: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3789: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3790: DOCTYPE state</a>.</dd>
3791:
1.755 mike 3792: </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 3793:
3794: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3795:
3796: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3797: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3798:
3799: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3800: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3801: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3802: token. Switch to the <a href="#data-state">data state</a>.</dd>
3803:
3804: <dt>EOF</dt>
3805: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3806: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3807: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3808:
3809: <dt>Anything else</dt>
3810: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3811: token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
3812: identifier (double-quoted) state</a>.</dd>
3813:
1.755 mike 3814: </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 3815:
3816: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3817:
3818: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3819: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3820:
3821: <dt>U+003E GREATER-THAN SIGN (>)</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
3824: token. Switch to the <a href="#data-state">data state</a>.</dd>
3825:
3826: <dt>EOF</dt>
3827: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3828: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3829: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3830:
3831: <dt>Anything else</dt>
3832: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3833: token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
3834: identifier (single-quoted) state</a>.</dd>
3835:
1.755 mike 3836: </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 3837:
3838: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3839:
3840: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3841: <dt>U+000A LINE FEED (LF)</dt>
3842: <dt>U+000C FORM FEED (FF)</dt>
3843: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3844: <dt>U+0020 SPACE</dt>
1.541 mike 3845: <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
3846: identifiers state</a>.</dd>
1.444 mike 3847:
3848: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3849: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3850: state</a>.</dd>
3851:
3852: <dt>U+0022 QUOTATION MARK (")</dt>
3853: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3854: identifier to the empty string (not missing), then switch to the
3855: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3856:
3857: <dt>U+0027 APOSTROPHE (')</dt>
3858: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3859: identifier to the empty string (not missing), then switch to the
3860: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3861:
3862: <dt>EOF</dt>
3863: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3864: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3865: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3866:
3867: <dt>Anything else</dt>
3868: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3869: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3870: DOCTYPE state</a>.</dd>
3871:
1.755 mike 3872: </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 3873:
3874: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3875:
3876: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3877: <dt>U+000A LINE FEED (LF)</dt>
3878: <dt>U+000C FORM FEED (FF)</dt>
3879: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3880: <dt>U+0020 SPACE</dt>
1.541 mike 3881: <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
3882: state</a>.</dd>
1.444 mike 3883:
3884: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3885: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3886: state</a>.</dd>
1.1 mike 3887:
3888: <dt>U+0022 QUOTATION MARK (")</dt>
3889: <dd>Set the DOCTYPE token's system identifier to the empty string
3890: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3891: (double-quoted) state</a>.</dd>
3892:
3893: <dt>U+0027 APOSTROPHE (')</dt>
3894: <dd>Set the DOCTYPE token's system identifier to the empty string
3895: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3896: (single-quoted) state</a>.</dd>
3897:
3898: <dt>EOF</dt>
3899: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3900: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3901: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3902:
3903: <dt>Anything else</dt>
3904: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3905: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3906: DOCTYPE state</a>.</dd>
3907:
1.755 mike 3908: </dl><h5 id="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 3909:
3910: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3911:
3912: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3913: <dt>U+000A LINE FEED (LF)</dt>
3914: <dt>U+000C FORM FEED (FF)</dt>
3915: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3916: <dt>U+0020 SPACE</dt>
3917: <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
3918: state</a>.</dd>
3919:
1.620 mike 3920: <dt>U+0022 QUOTATION MARK (")</dt>
3921: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3922: identifier to the empty string (not missing), then switch to the
3923: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3924:
3925: <dt>U+0027 APOSTROPHE (')</dt>
3926: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3927: identifier to the empty string (not missing), then switch to the
3928: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3929:
3930: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3931: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3932: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3933: token. Switch to the <a href="#data-state">data state</a>.</dd>
3934:
1.444 mike 3935: <dt>EOF</dt>
3936: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3937: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3938: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3939:
3940: <dt>Anything else</dt>
1.620 mike 3941: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3942: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3943: DOCTYPE state</a>.</dd>
1.444 mike 3944:
1.755 mike 3945: </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 3946:
3947: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3948:
3949: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3950: <dt>U+000A LINE FEED (LF)</dt>
3951: <dt>U+000C FORM FEED (FF)</dt>
3952: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3953: <dt>U+0020 SPACE</dt>
3954: <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
3955:
3956: <dt>U+0022 QUOTATION MARK (")</dt>
3957: <dd>Set the DOCTYPE token's system identifier to the empty string
3958: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3959: (double-quoted) state</a>.</dd>
3960:
3961: <dt>U+0027 APOSTROPHE (')</dt>
3962: <dd>Set the DOCTYPE token's system identifier to the empty string
3963: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3964: (single-quoted) state</a>.</dd>
3965:
3966: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3967: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3968: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3969: token. Switch to the <a href="#data-state">data state</a>.</dd>
3970:
3971: <dt>EOF</dt>
3972: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3973: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3974: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3975:
3976: <dt>Anything else</dt>
3977: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3978: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3979: DOCTYPE state</a>.</dd>
3980:
1.755 mike 3981: </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 3982:
3983: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3984:
3985: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541 mike 3986: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
3987: state</a>.</dd>
1.1 mike 3988:
3989: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3990: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3991: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3992: token. Switch to the <a href="#data-state">data state</a>.</dd>
3993:
3994: <dt>EOF</dt>
3995: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3996: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3997: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3998:
3999: <dt>Anything else</dt>
1.541 mike 4000: <dd>Append the <a href="#current-input-character">current input character</a> to the current
4001: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1 mike 4002: identifier (double-quoted) state</a>.</dd>
4003:
1.755 mike 4004: </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 4005:
4006: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4007:
4008: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541 mike 4009: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4010: state</a>.</dd>
1.1 mike 4011:
4012: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4013: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4014: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4015: token. Switch to the <a href="#data-state">data state</a>.</dd>
4016:
4017: <dt>EOF</dt>
4018: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4019: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4020: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4021:
4022: <dt>Anything else</dt>
1.541 mike 4023: <dd>Append the <a href="#current-input-character">current input character</a> to the current
4024: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1 mike 4025: identifier (single-quoted) state</a>.</dd>
4026:
1.755 mike 4027: </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 4028:
4029: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4030:
4031: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4032: <dt>U+000A LINE FEED (LF)</dt>
4033: <dt>U+000C FORM FEED (FF)</dt>
4034: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4035: <dt>U+0020 SPACE</dt>
1.541 mike 4036: <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4037: state</a>.</dd>
1.1 mike 4038:
4039: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4040: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
4041: state</a>.</dd>
4042:
4043: <dt>EOF</dt>
4044: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4045: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4046: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4047:
4048: <dt>Anything else</dt>
4049: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
4050: state</a>. (This does <em>not</em> set the DOCTYPE token's
4051: <i>force-quirks flag</i> to <i>on</i>.)</dd>
4052:
1.755 mike 4053: </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 4054:
4055: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4056:
4057: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
4058: <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
4059: state</a>.</dd>
4060:
4061: <dt>EOF</dt>
4062: <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
4063: <a href="#data-state">data state</a>.</dd>
4064:
4065: <dt>Anything else</dt>
4066: <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
4067:
1.755 mike 4068: </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 4069:
4070: <p>Consume every character up to the next occurrence of the three
4071: character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
4072: BRACKET U+003E GREATER-THAN SIGN (<code title="">]]></code>), or the
4073: end of the file (EOF), whichever comes first. Emit a series of
4074: character tokens consisting of all the characters consumed except
4075: the matching three character sequence at the end (if one was found
4076: before the end of the file).</p>
4077:
4078: <p>Switch to the <a href="#data-state">data state</a>.</p>
4079:
4080: <p>If the end of the file was reached, reconsume the EOF
4081: character.</p>
4082:
4083:
4084:
1.755 mike 4085: <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 4086:
4087: <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
4088: reference</dfn>. This definition is used when parsing character
1.299 mike 4089: references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1 mike 4090: text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
4091: state">in attributes</a>.</p>
4092:
4093: <p>The behavior depends on the identity of the next character (the
4094: one immediately after the U+0026 AMPERSAND character):</p>
4095:
4096: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4097: <dt>U+000A LINE FEED (LF)</dt>
4098: <dt>U+000C FORM FEED (FF)</dt>
4099: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4100: <dt>U+0020 SPACE</dt>
4101: <dt>U+003C LESS-THAN SIGN</dt>
4102: <dt>U+0026 AMPERSAND</dt>
4103: <dt>EOF</dt>
4104: <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
4105:
4106: <dd>Not a character reference. No characters are consumed, and
4107: nothing is returned. (This is not an error, either.)</dd>
4108:
4109:
4110: <dt>U+0023 NUMBER SIGN (#)</dt>
4111:
4112: <dd>
4113:
4114: <p>Consume the U+0023 NUMBER SIGN.</p>
4115:
4116: <p>The behavior further depends on the character after the U+0023
4117: NUMBER SIGN:</p>
4118:
4119: <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
4120: <dt>U+0058 LATIN CAPITAL LETTER X</dt>
4121:
4122: <dd>
4123:
4124: <p>Consume the X.</p>
4125:
4126: <p>Follow the steps below, but using the range of characters
1.464 mike 4127: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
4128: SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
4129: CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
4130: words, 0-9, A-F, a-f).</p>
1.1 mike 4131:
4132: <p>When it comes to interpreting the number, interpret it as a
4133: hexadecimal number.</p>
4134:
4135: </dd>
4136:
4137:
4138: <dt>Anything else</dt>
4139:
4140: <dd>
4141:
4142: <p>Follow the steps below, but using the range of characters
1.464 mike 4143: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1 mike 4144:
4145: <p>When it comes to interpreting the number, interpret it as a
4146: decimal number.</p>
4147:
4148: </dd>
4149:
4150: </dl><p>Consume as many characters as match the range of characters
4151: given above.</p>
4152:
4153: <p>If no characters match the range, then don't consume any
4154: characters (and unconsume the U+0023 NUMBER SIGN character and, if
4155: appropriate, the X character). This is a <a href="#parse-error">parse
4156: error</a>; nothing is returned.</p>
4157:
4158: <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
4159: that too. If it isn't, there is a <a href="#parse-error">parse
4160: error</a>.</p>
4161:
4162: <p>If one or more characters match the range, then take them all
4163: and interpret the string of characters as a number (either
4164: hexadecimal or decimal as appropriate).</p>
4165:
4166: <p>If that number is one of the numbers in the first column of the
4167: following table, then this is a <a href="#parse-error">parse error</a>. Find the
4168: row with that number in the first column, and return a character
4169: token for the Unicode character given in the second column of that
4170: row.</p>
4171:
4172: <table><thead><tr><th>Number </th><th colspan="2">Unicode character
4173: </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
4174: </td></tr><tr><td>0x0D </td><td>U+000A </td><td>LINE FEED (LF)
1.464 mike 4175: </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (€)
1.1 mike 4176: </td></tr><tr><td>0x81 </td><td>U+0081 </td><td><control>
1.464 mike 4177: </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (‚)
4178: </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (ƒ)
4179: </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK („)
4180: </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (…)
4181: </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (†)
4182: </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (‡)
4183: </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
4184: </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (‰)
4185: </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (Š)
4186: </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
4187: </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (Œ)
1.1 mike 4188: </td></tr><tr><td>0x8D </td><td>U+008D </td><td><control>
1.464 mike 4189: </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
1.1 mike 4190: </td></tr><tr><td>0x8F </td><td>U+008F </td><td><control>
4191: </td></tr><tr><td>0x90 </td><td>U+0090 </td><td><control>
1.464 mike 4192: </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (‘)
4193: </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (’)
4194: </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (“)
4195: </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (”)
4196: </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (•)
4197: </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (–)
4198: </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (—)
4199: </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (˜)
4200: </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (™)
4201: </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (š)
4202: </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
4203: </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (œ)
1.1 mike 4204: </td></tr><tr><td>0x9D </td><td>U+009D </td><td><control>
1.464 mike 4205: </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (ž)
4206: </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
1.315 mike 4207: </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
4208: surrogates not allowed; see the comment in the "preprocessing the
4209: input stream" section for details --> or is greater than 0x10FFFF,
4210: then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
4211: REPLACEMENT CHARACTER.</p>
1.18 mike 4212:
4213: <p>Otherwise, return a character token for the Unicode character
1.1 mike 4214: whose code point is that number.
4215:
4216: <!-- this is the same as the equivalent list in the input stream
4217: section -->
4218: If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
4219: allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
4220: allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315 mike 4221: 0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
4222: 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
4223: 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
4224: 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
4225: 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
4226: 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
4227: 0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
4228: error</a>.</p>
1.1 mike 4229:
4230: </dd>
4231:
4232:
4233: <dt>Anything else</dt>
4234:
4235: <dd>
4236:
4237: <p>Consume the maximum number of characters possible, with the
4238: consumed characters matching one of the identifiers in the first
4239: column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
4240: <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
4241:
4242: <p>If no match can be made, then this is a <a href="#parse-error">parse
4243: error</a>. No characters are consumed, and nothing is
4244: returned.</p>
4245:
1.588 mike 4246: <p>If the last character matched is not a U+003B SEMICOLON
4247: character (;), there is a <a href="#parse-error">parse error</a>.</p>
1.1 mike 4248:
4249: <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
4250: attribute</a>, and the last character matched is not a U+003B
1.588 mike 4251: SEMICOLON character (;), and the next character is in the range
4252: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
4253: CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN
4254: SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for
4255: historical reasons, all the characters that were matched after the
4256: U+0026 AMPERSAND character (&) must be unconsumed, and nothing
4257: is returned.</p>
1.1 mike 4258:
4259: <p>Otherwise, return a character token for the character
4260: corresponding to the character reference name (as given by the
4261: second column of the <a href="named-character-references.html#named-character-references">named character references</a>
4262: table).</p>
4263:
4264: <div class="example">
4265:
4266: <p>If the markup contains <code title="">I'm &notit; I tell
4267: you</code>, the character reference is parsed as "not", as in,
4268: <code title="">I'm ¬it; I tell you</code>. But if the markup
4269: was <code title="">I'm &notin; I tell you</code>, the
4270: character reference would be parsed as "notin;", resulting in
4271: <code title="">I'm ∉ I tell you</code>.</p>
4272:
4273: </div>
4274:
4275: </dd>
4276:
1.266 mike 4277: </dl></div><div class="impl">
4278:
1.363 mike 4279: <!-- v2: One thing that this doesn't define is handling deeply
4280: nested documents. There are compatibility requirements around that:
4281: you can't throw away the elements altogether, consider Tux made only
4282: with opening <font> elements, one per character. Seems that the best
4283: thing to do is to close some formatting elements from the middle of
4284: the stack when you hit a limit, or something. -->
4285:
1.755 mike 4286: <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 4287:
4288: <p>The input to the tree construction stage is a sequence of tokens
4289: from the <a href="#tokenization">tokenization</a> stage. The tree construction
1.810 mike 4290: stage is associated with a DOM <code><a href="infrastructure.html#document">Document</a></code> object when a
1.1 mike 4291: parser is created. The "output" of this stage consists of
4292: dynamically modifying or extending that document's DOM tree.</p>
4293:
4294: <p>This specification does not define when an interactive user agent
1.810 mike 4295: has to render the <code><a href="infrastructure.html#document">Document</a></code> so that it is available to
1.1 mike 4296: the user, or when it has to begin accepting user input.</p>
4297:
4298: <p>As each token is emitted from the tokenizer, the user agent must
4299: process the token according to the rules given in the section
4300: corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
4301:
4302: <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
4303: character</dfn> into a node, if that node has a child immediately
4304: before where the character is to be inserted, and that child is a
4305: <code>Text</code> node, and that <code>Text</code> node was the last
4306: node that the parser inserted into the document, then the character
4307: must be appended to that <code>Text</code> node; otherwise, a new
4308: <code>Text</code> node whose data is just that character must be
4309: inserted in the appropriate place.</p>
4310:
4311: <div class="example">
4312:
4313: <p>Here are some sample inputs to the parser and the corresponding
4314: number of text nodes that they result in, assuming a user agent
4315: that executes scripts.</p>
4316:
4317: <table><thead><tr><th>Input </th><th>Number of text nodes
4318: </th></tr></thead><tbody><tr><td><pre>A<script>
4319: var script = document.getElementsByTagName('script')[0];
4320: document.body.removeChild(script);
4321: </script>B</pre>
4322: </td><td>Two adjacent text nodes in the document, containing "A" and "B".
4323: </td></tr><tr><td><pre>A<script>
4324: var text = document.createTextNode('B');
4325: document.body.appendChild(text);
4326: </script>C</pre>
4327: </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
4328: </td></tr><tr><td><pre>A<script>
4329: var text = document.getElementsByTagName('script')[0].firstChild;
4330: text.data = 'B';
4331: document.body.appendChild(text);
4332: </script>B</pre>
4333: </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
4334: </td></tr><tr><td><pre>A<table>B<tr>C</tr>C</table></pre>
4335: </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>.)
4336: </td></tr><tr><td><pre>A<table><tr> B</tr> B</table></pre>
4337: </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>.)
4338: </td></tr><tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
4339: </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.)
4340: </td></tr></tbody></table></div>
4341:
4342: <p id="mutation-during-parsing">DOM mutation events must not fire
4343: for changes caused by the UA parsing the document. (Conceptually,
4344: the parser is not mutating the DOM, it is constructing it.) This
1.159 mike 4345: 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 4346:
4347: <p class="note">Not all of the tag names mentioned below are
4348: conformant tag names in this specification; many are included to
4349: handle legacy content. They still form part of the algorithm that
4350: implementations are required to implement to claim conformance.</p>
4351:
4352: <p class="note">The algorithm described below places no limit on the
4353: depth of the DOM tree generated, or on the length of tag names,
4354: attribute names, attribute values, text nodes, etc. While
4355: implementors are encouraged to avoid arbitrary limits, it is
4356: recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445 mike 4357: concerns</a> will likely force user agents to impose nesting depth
4358: constraints.</p>
1.1 mike 4359:
4360:
1.755 mike 4361: <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 4362:
4363: <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
4364: element for the token">create an element for a token</dfn> in a
4365: particular namespace, the UA must create a node implementing the
4366: interface appropriate for the element type corresponding to the tag
4367: name of the token in the given namespace (as given in the
4368: 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 4369: element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, this specification
1.1 mike 4370: defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
4371: the tag name being the name of that element, with the node being in
4372: the given namespace, and with the attributes on the node being those
4373: given in the given token.</p>
4374:
1.724 mike 4375: <p>The interface appropriate for an element in the <a href="infrastructure.html#html-namespace-0">HTML
1.426 mike 4376: namespace</a> that is not defined in this specification (or
4377: <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44 mike 4378: <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1 mike 4379: interface is not defined by that namespace's specification must use
1.810 mike 4380: the interface <code><a href="infrastructure.html#element">Element</a></code>.</p>
1.1 mike 4381:
4382: <p>When a <a href="forms.html#category-reset" title="category-reset">resettable</a> element is
4383: created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
4384: invoked once the attributes are set. (This initializes the element's
4385: <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
4386: attributes.)</p>
4387:
4388: <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
4389: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
1.724 mike 4390: for the token</a> in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, and then
1.1 mike 4391: append this node to the <a href="#current-node">current node</a>, and push it onto
4392: the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
4393: <a href="#current-node">current node</a>.</p>
4394:
4395: <p>The steps below may also require that the UA insert an HTML
4396: element in a particular place, in which case the UA must follow the
4397: same steps except that it must insert or append the new node in the
4398: location specified instead of appending it to the <a href="#current-node">current
4399: node</a>. (This happens in particular during the parsing of
4400: tables with invalid content.)</p>
4401:
4402: <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
4403: algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
4404: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
4405: 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
4406: <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
4407: created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
4408: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
4409: inserting it wherever it is to be inserted.</p>
4410:
4411: <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
4412: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
4413: for the token</a> in the given namespace, and then append this
4414: node to the <a href="#current-node">current node</a>, and push it onto the
4415: <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
1.724 mike 4416: <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 4417: whose value is not exactly the same as the element's namespace, that
4418: is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
4419: element has an <code title="">xmlns:xlink</code> attribute in the
1.724 mike 4420: <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="infrastructure.html#xlink-namespace">XLink
1.1 mike 4421: Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
4422:
4423: <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
4424: attributes</dfn> for a token, then, if the token has an attribute
4425: named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
4426:
4427: <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
4428: attributes</dfn> for a token, then, for each attribute on the token
4429: whose attribute name is one of the ones in the first column of the
4430: following table, change the attribute's name to the name given in
4431: the corresponding cell in the second column. (This fixes the case of
4432: SVG attributes that are not all lowercase.)</p>
4433:
4434: <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
4435: </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
4436: </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
4437: </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
4438: </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
4439: </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
4440: </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
4441: </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
4442: </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
4443: </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
4444: </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
4445: </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
4446: </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
4447: </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
4448: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
4449: </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
4450: </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
4451: </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
4452: </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
4453: </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
4454: </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
4455: </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
4456: </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
4457: </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
4458: </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
4459: </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
4460: </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
4461: </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
4462: </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
4463: </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
4464: </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
4465: </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
4466: </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
4467: </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
4468: </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
4469: </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
4470: </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
4471: </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
4472: </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
4473: </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
4474: </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
4475: </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
4476: </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
4477: </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
4478: </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
4479: </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
4480: </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
4481: </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
4482: </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
4483: </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
4484: </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
4485: </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
4486: </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
4487: </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
4488: </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
4489: </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
4490: </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
4491: </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
4492: </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
4493: </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
4494: </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
4495: </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
4496: </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
4497: </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
4498: foreign attributes</dfn> for a token, then, if any of the attributes
4499: on the token match the strings given in the first column of the
4500: following table, let the attribute be a namespaced attribute, with
4501: the prefix being the string given in the corresponding cell in the
4502: second column, the local name being the string given in the
4503: corresponding cell in the third column, and the namespace being the
4504: namespace given in the corresponding cell in the fourth
4505: column. (This fixes the use of namespaced attributes, in particular
4506: <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
4507: the <span>XML namespace</span></a>.)</p>
4508:
4509: <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
1.724 mike 4510: </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>
4511: </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>
4512: </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>
4513: </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>
4514: </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>
4515: </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>
4516: </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>
4517: </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 -->
4518: </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>
4519: </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>
4520: </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>
4521: </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 4522: </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 4523: <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
4524: following steps. These algorithms are always invoked in response to
4525: a start tag token.</p>
4526:
4527: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
4528:
1.91 mike 4529: <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541 mike 4530: text element parsing algorithm</a>, switch the tokenizer to the
4531: <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
4532: was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
4533: switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1 mike 4534:
4535: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
4536: <a href="#insertion-mode">insertion mode</a>.</p>
4537:
1.540 mike 4538: </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 4539:
1.755 mike 4540: </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 4541:
4542: <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
4543: tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422 mike 4544: <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 4545: <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
4546: <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
4547: <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
4548: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4549: elements</a>.</p>
4550:
4551: <p>If a step requires the UA to generate implied end tags but lists
4552: an element to exclude from the process, then the UA must perform the
4553: above steps as if that element was not in the above list.</p>
4554:
4555:
1.755 mike 4556: <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 4557:
4558: <p>Foster parenting happens when content is misnested in tables.</p>
4559:
4560: <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
4561: parent">foster parented</dfn>, the node <var title="">node</var>
4562: must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4563:
4564: <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
4565: 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
4566: elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
4567: such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4568: the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
4569: case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
4570: element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159 mike 4571: <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1 mike 4572: <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
4573: elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4574: <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
4575: node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
4576: the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4577: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
4578:
4579: <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
4580: 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
4581: elements</a>, then <var title="">node</var> must be inserted
4582: immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4583: the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
4584: element</a></i>; otherwise, <var title="">node</var> must be
4585: <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4586:
4587:
4588:
1.755 mike 4589: <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 4590:
4591: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
4592: mode: initial">initial</a>", tokens must be handled as follows:</p>
4593:
4594: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4595: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4596: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4597: <dd>
4598: <p>Ignore the token.</p>
4599: </dd>
4600:
4601: <dt>A comment token</dt>
4602: <dd>
1.810 mike 4603: <p>Append a <code>Comment</code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 4604: object with the <code title="">data</code> attribute set to the
4605: data given in the comment token.</p>
4606: </dd>
4607:
4608: <dt>A DOCTYPE token</dt>
4609: <dd>
4610:
4611: <p>If the DOCTYPE token's name is not a
4612: <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
4613: missing, or the token's system identifier is neither missing nor a
4614: <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465 mike 4615: "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1 mike 4616: conditions in the following list are matched, then there is a
4617: <a href="#parse-error">parse error</a>. If one of the sets of conditions in the
4618: following list is matched, then there is an <dfn id="obsolete-permitted-doctype">obsolete
4619: permitted DOCTYPE</dfn>.</p>
4620:
4621: <ul><!-- only things that trigger no-quirks mode and were valid in
1.688 mike 4622: 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>
4623: match for the string "<code title="">html</code>", the token's
4624: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4625: "<code title="">-//W3C//DTD HTML 4.0//EN</code>", and
4626: the token's system identifier is either missing or the
1.1 mike 4627: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
4628:
1.688 mike 4629: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4630: match for the string "<code title="">html</code>", the token's
4631: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4632: "<code title="">-//W3C//DTD HTML 4.01//EN</code>", and
4633: the token's system identifier is either missing or the
1.1 mike 4634: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
4635:
1.688 mike 4636: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4637: match for the string "<code title="">html</code>", the token's
4638: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4639: "<code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>",
1.1 mike 4640: and the token's system identifier is the
4641: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
4642:
1.688 mike 4643: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4644: match for the string "<code title="">html</code>", the token's
4645: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4646: "<code title="">-//W3C//DTD XHTML 1.1//EN</code>", and
4647: the token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
1.1 mike 4648: string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
4649:
4650: </ul><p>Conformance checkers may, based on the values (including
4651: presence or lack thereof) of the DOCTYPE token's name, public
4652: identifier, or system identifier, switch to a conformance checking
4653: mode for another language (e.g. based on the DOCTYPE token a
4654: conformance checker could recognize that the document is an
1.183 mike 4655: HTML4-era document, and defer to an HTML4 conformance
1.1 mike 4656: checker.)</p>
4657:
4658: <p>Append a <code>DocumentType</code> node to the
1.810 mike 4659: <code><a href="infrastructure.html#document">Document</a></code> node, with the <code title="">name</code>
1.1 mike 4660: attribute set to the name given in the DOCTYPE token, or the empty
4661: string if the name was missing; the <code title="">publicId</code>
4662: attribute set to the public identifier given in the DOCTYPE token,
4663: or the empty string if the public identifier was missing; the
4664: <code title="">systemId</code> attribute set to the system
4665: identifier given in the DOCTYPE token, or the empty string if the
4666: system identifier was missing; and the other attributes specific
4667: to <code>DocumentType</code> objects set to null and empty lists
4668: as appropriate. Associate the <code>DocumentType</code> node with
1.810 mike 4669: the <code><a href="infrastructure.html#document">Document</a></code> object so that it is returned as the
1.1 mike 4670: value of the <code title="">doctype</code> attribute of the
1.810 mike 4671: <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4672:
4673: <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
4674: one of the conditions in the following list, then set the
1.810 mike 4675: <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
1.1 mike 4676:
4677: <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
1.688 mike 4678: <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 4679: <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
4680: <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4681: <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4682: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
4683: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
4684: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
4685: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
4686: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
4687: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
4688: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
4689: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
4690: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
4691: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4692: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
4693: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
4694: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
4695: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
4696: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
4697: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
4698: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
4699: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
4700: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
4701: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
4702: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
4703: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
4704: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
4705: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
4706: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
4707: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
4708: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
4709: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
4710: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
4711: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
4712: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
4713: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
4714: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
4715: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
4716: <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
4717: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
4718: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
4719: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
4720: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
4721: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
4722: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
4723: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
4724: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
4725: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
4726: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
4727: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
4728: <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
4729: <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
4730: <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
4731: <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
4732: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
4733: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
4734: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
4735: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
4736: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4737: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
4738: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
4739: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
4740: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
4741: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
4742: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
4743: <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
4744: <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
4745: <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>-->
4746: <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
4747: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
4748: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
4749: <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
4750: <li> The public identifier is set to: "<code title="">HTML</code>" </li>
4751: <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
4752: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4753: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
4754: </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
1.810 mike 4755: in the following list, then set the <code><a href="infrastructure.html#document">Document</a></code> to
1.1 mike 4756: <a href="dom.html#limited-quirks-mode">limited quirks mode</a>:</p>
4757:
4758: <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
4759: <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
4760: <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4761: <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 4762: </ul><p>The system identifier and public identifier strings must be
4763: compared to the values given in the lists above in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
4764: case-insensitive</a> manner. A system identifier whose value is
4765: the empty string is not considered missing for the purposes of the
4766: conditions above.</p>
1.1 mike 4767:
4768: <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>
4769:
4770: </dd>
4771:
4772: <dt>Anything else</dt>
4773: <dd>
4774:
1.727 mike 4775: <p>If the document is <em>not</em> <a href="text-level-semantics.html#an-iframe-srcdoc-document">an <code>iframe</code>
4776: <code title="attr-iframe-srcdoc">srcdoc</code> document</a>,
4777: then this is a <a href="#parse-error">parse error</a>; set the
1.810 mike 4778: <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
1.1 mike 4779:
1.727 mike 4780: <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 4781: reprocess the current token.</p>
4782:
4783: </dd>
4784:
1.755 mike 4785: </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 4786:
4787: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
4788: mode: before html">before html</a>", tokens must be handled as follows:</p>
4789:
4790: <dl class="switch"><dt>A DOCTYPE token</dt>
4791: <dd>
4792: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4793: </dd>
4794:
4795: <dt>A comment token</dt>
4796: <dd>
1.810 mike 4797: <p>Append a <code>Comment</code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 4798: object with the <code title="">data</code> attribute set to the
4799: data given in the comment token.</p>
4800: </dd>
4801:
4802: <dt>A character token that is one of U+0009 CHARACTER
4803: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4804: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4805: <dd>
4806: <p>Ignore the token.</p>
4807: </dd>
4808:
4809: <dt>A start tag whose tag name is "html"</dt>
4810: <dd>
4811:
1.724 mike 4812: <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 4813: namespace</a>. Append it to the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 4814: object. Put this element in the <a href="#stack-of-open-elements">stack of open
4815: elements</a>.</p>
4816:
1.810 mike 4817: <p id="parser-appcache">If the <code><a href="infrastructure.html#document">Document</a></code> is being
1.1 mike 4818: loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
4819: <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
4820: has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute,
4821: then <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolve</a> the value of that
4822: attribute to an <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly
4823: created element, and if that is successful, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
1.29 mike 4824: algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
4825: any <a href="infrastructure.html#url-fragment" title="url-fragment"><fragment></a> component
4826: removed; otherwise, if there is no such attribute or resolving it
4827: fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application
4828: cache selection algorithm</a> with no manifest. The algorithm
1.810 mike 4829: must be passed the <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4830:
4831: <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>
4832:
4833: </dd>
4834:
1.334 mike 4835: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4836: <dd>
4837: <p>Act as described in the "anything else" entry below.</p>
4838: </dd>
4839:
4840: <dt>Any other end tag</dt>
4841: <dd>
4842: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4843: </dd>
4844:
1.1 mike 4845: <dt>Anything else</dt>
4846: <dd>
4847:
1.159 mike 4848: <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.810 mike 4849: <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 4850: of open elements</a>.</p>
4851:
1.810 mike 4852: <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 4853: context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
4854: algorithm</a> with no manifest, passing it the
1.810 mike 4855: <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4856:
4857: <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
4858: reprocess the current token.</p>
4859:
4860: </dd>
4861:
4862: </dl><p>The root element can end up being removed from the
1.810 mike 4863: <code><a href="infrastructure.html#document">Document</a></code> object, e.g. by scripts; nothing in particular
1.1 mike 4864: happens in such cases, content continues being appended to the nodes
4865: as described in the next section.</p>
4866:
4867:
1.755 mike 4868: <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 4869:
4870: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
4871: mode: before head">before head</a>", tokens must be handled as follows:</p>
4872:
4873: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4874: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4875: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4876: <dd>
4877: <p>Ignore the token.</p> <!-- :-( -->
4878: </dd>
4879:
4880: <dt>A comment token</dt>
4881: <dd>
4882: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
4883: node</a> with the <code title="">data</code> attribute set to
4884: the data given in the comment token.</p>
4885: </dd>
4886:
4887: <dt>A DOCTYPE token</dt>
4888: <dd>
4889: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4890: </dd>
4891:
4892: <dt>A start tag whose tag name is "html"</dt>
4893: <dd>
4894: <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
4895: mode</a>.</p>
4896: </dd>
4897:
4898: <dt>A start tag whose tag name is "head"</dt>
4899: <dd>
4900:
4901: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
4902:
4903: <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159 mike 4904: to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 4905:
4906: <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>
4907:
4908: </dd>
4909:
4910: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4911: <dd>
4912:
4913: <p>Act as if a start tag token with the tag name "head" and no
4914: attributes had been seen, then reprocess the current token.</p>
4915:
4916: </dd>
4917:
4918: <dt>Any other end tag</dt>
4919: <dd>
4920:
4921: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4922:
4923: </dd>
4924:
4925: <dt>Anything else</dt>
4926: <dd>
4927:
4928: <p>Act as if a start tag token with the tag name "head" and no
4929: attributes had been seen, then reprocess the current
4930: token.</p>
4931:
4932: </dd>
4933:
1.755 mike 4934: </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 4935:
4936: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
4937: mode: in head">in head</a>", tokens must be handled as follows:</p>
4938:
4939: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4940: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4941: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4942: <dd>
4943: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
4944: the <a href="#current-node">current node</a>.</p>
4945: </dd>
4946:
4947: <dt>A comment token</dt>
4948: <dd>
4949: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
4950: node</a> with the <code title="">data</code> attribute set to
4951: the data given in the comment token.</p>
4952: </dd>
4953:
4954: <dt>A DOCTYPE token</dt>
4955: <dd>
4956: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4957: </dd>
4958:
4959: <dt>A start tag whose tag name is "html"</dt>
4960: <dd>
4961: <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
4962: mode</a>.</p>
4963: </dd>
4964:
4965: <dt>A start tag whose tag name is one of: "base", "command",
4966: "link"</dt>
4967: <dd>
4968:
4969: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
4970: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4971: elements</a>.</p>
4972:
4973: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
4974: token's <i>self-closing flag</i></a>, if it is set.</p>
4975:
4976: </dd>
4977:
4978: <dt>A start tag whose tag name is "meta"</dt>
4979: <dd>
4980:
4981: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
4982: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4983: elements</a>.</p>
4984:
4985: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
4986: token's <i>self-closing flag</i></a>, if it is set.</p>
4987:
4988: <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
4989: value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
4990: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
4991: encoding</a> to the encoding given by the value of the
4992: <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
4993:
4994: <p>Otherwise, if the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">content</a></code> attribute, and
4995: applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
4996: Content-Type</a> to its value returns a supported encoding
4997: <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
4998: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
4999: encoding</a> to the encoding <var title="">encoding</var>.</p>
5000:
5001: </dd>
5002:
5003: <dt>A start tag whose tag name is "title"</dt>
5004: <dd>
5005: <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
5006: </dd>
5007:
5008: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
5009: <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
5010: <dd>
1.91 mike 5011: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 5012: </dd>
5013:
5014: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
5015: <dd>
5016:
5017: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5018:
5019: <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
5020: noscript</a>".</p>
5021:
5022: </dd>
5023:
5024: <dt id="scriptTag">A start tag whose tag name is "script"</dt>
5025: <dd>
5026:
5027: <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
1.724 mike 5028: <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</p></li>
1.1 mike 5029:
5030: <li>
5031:
5032: <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
5033:
5034: <p class="note">This ensures that, if the script is external,
1.159 mike 5035: any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1 mike 5036: calls in the script will execute in-line, instead of blowing the
5037: document away, as would happen in most other cases. It also
5038: prevents the script from executing until the end tag is
5039: seen.</p>
5040:
5041: </li>
5042:
5043: <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
5044: fragment parsing algorithm</a>, then mark the
1.484 mike 5045: <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
5046: started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1 mike 5047:
5048: <li><p>Append the new element to the <a href="#current-node">current node</a>
5049: and push it onto the <a href="#stack-of-open-elements">stack of open
5050: elements</a>.</p></li>
5051:
1.541 mike 5052: <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
5053: state</a>.</p></li>
1.1 mike 5054:
5055: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
5056: <a href="#insertion-mode">insertion mode</a>.</p>
5057:
1.540 mike 5058: </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 5059:
5060: </ol></dd>
5061:
5062: <dt>An end tag whose tag name is "head"</dt>
5063: <dd>
5064:
5065: <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159 mike 5066: <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 5067: elements</a>.</p>
5068:
5069: <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>
5070:
5071: </dd>
5072:
5073: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5074: <dd>
5075: <p>Act as described in the "anything else" entry below.</p>
5076: </dd>
5077:
5078: <dt>A start tag whose tag name is "head"</dt>
5079: <dt>Any other end tag</dt>
5080: <dd>
5081: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5082: </dd>
5083:
5084: <dt>Anything else</dt>
5085: <dd>
5086:
5087: <!-- can't get here with an EOF and a fragment case -->
5088:
5089: <p>Act as if an end tag token with the tag name "head" had
5090: been seen, and reprocess the current token.</p>
5091:
5092: </dd>
5093:
1.755 mike 5094: </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 5095:
5096: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
5097: mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
5098:
5099: <dl class="switch"><dt>A DOCTYPE token</dt>
5100: <dd>
5101: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5102: </dd>
5103:
5104: <dt>A start tag whose tag name is "html"</dt>
5105: <dd>
5106: <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
5107: mode</a>.</p>
5108: </dd>
5109:
5110: <dt>An end tag whose tag name is "noscript"</dt>
5111: <dd>
5112:
5113: <p>Pop the <a href="#current-node">current node</a> (which will be a
5114: <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
5115: elements</a>; the new <a href="#current-node">current node</a> will be a
1.159 mike 5116: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 5117:
5118: <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>
5119:
5120: </dd>
5121:
5122: <dt>A character token that is one of U+0009 CHARACTER
5123: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
5124: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
5125: <dt>A comment token</dt>
5126: <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
5127: <dd>
5128: <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
5129: mode</a>.</p>
5130: </dd>
5131:
5132: <dt>An end tag whose tag name is "br"</dt>
5133: <dd>
5134: <p>Act as described in the "anything else" entry below.</p>
5135: </dd>
5136:
5137: <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
5138: <dt>Any other end tag</dt>
5139: <dd>
5140: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5141: </dd>
5142:
5143: <dt>Anything else</dt>
5144: <dd>
5145:
5146: <!-- can't get here with an EOF and a fragment case -->
5147:
5148: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
5149: name "noscript" had been seen and reprocess the current
5150: token.</p>
5151:
5152: </dd>
5153:
1.755 mike 5154: </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 5155:
5156: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
5157: mode: after head">after head</a>", tokens must be handled as follows:</p>
5158:
5159: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
5160: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
5161: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
5162: <dd>
5163: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
5164: the <a href="#current-node">current node</a>.</p>
5165: </dd>
5166:
5167: <dt>A comment token</dt>
5168: <dd>
5169: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
5170: node</a> with the <code title="">data</code> attribute set to
5171: the data given in the comment token.</p>
5172: </dd>
5173:
5174: <dt>A DOCTYPE token</dt>
5175: <dd>
5176: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5177: </dd>
5178:
5179: <dt>A start tag whose tag name is "html"</dt>
5180: <dd>
5181: <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
5182: mode</a>.</p>
5183: </dd>
5184:
5185: <dt>A start tag whose tag name is "body"</dt>
5186: <dd>
5187:
5188: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5189:
5190: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5191:
5192: <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>
5193:
5194: </dd>
5195:
5196: <dt>A start tag whose tag name is "frameset"</dt>
5197: <dd>
5198:
5199: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5200:
5201: <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>
5202:
5203: </dd>
5204:
5205: <dt>A start tag token whose tag name is one of: "base", "link",
5206: "meta", "noframes", "script", "style", "title"</dt>
5207: <dd>
5208:
5209: <p><a href="#parse-error">Parse error</a>.</p>
5210:
5211: <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
5212: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5213:
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:
5217: <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
5218: of open elements</a>.</p>
5219:
5220: <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
5221: pointer</a> cannot be null at this point.</p>
5222:
5223: </dd>
5224:
5225: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5226: <dd>
5227: <p>Act as described in the "anything else" entry below.</p>
5228: </dd>
5229:
5230: <dt>A start tag whose tag name is "head"</dt>
5231: <dt>Any other end tag</dt>
5232: <dd>
5233: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5234: </dd>
5235:
5236: <dt>Anything else</dt>
5237: <dd>
5238: <p>Act as if a start tag token with the tag name "body" and no
5239: attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
5240: flag</a> back to "ok", and then reprocess the current
5241: token.</p>
5242: </dd>
5243:
1.755 mike 5244: </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 5245:
5246: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
5247: mode: in body">in body</a>", tokens must be handled as follows:</p>
5248:
5249: <dl class="switch"><dt>A character token</dt>
5250: <dd>
5251:
5252: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5253: any.</p>
5254:
5255: <p><a href="#insert-a-character" title="insert a character">Insert the token's
5256: character</a> into the <a href="#current-node">current node</a>.</p>
5257:
5258: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
5259: LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
5260: (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
5261: flag</a> to "not ok".</p>
5262:
5263: </dd>
5264:
5265: <dt>A comment token</dt>
5266: <dd>
5267: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
5268: node</a> with the <code title="">data</code> attribute set to
5269: the data given in the comment token.</p>
5270: </dd>
5271:
5272: <dt>A DOCTYPE token</dt>
5273: <dd>
5274: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5275: </dd>
5276:
5277: <dt>A start tag whose tag name is "html"</dt>
5278: <dd>
5279: <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
5280: check to see if the attribute is already present on the top
5281: element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
5282: add the attribute and its corresponding value to that element.</p>
5283: </dd>
5284:
5285: <dt>A start tag token whose tag name is one of: "base", "command",
5286: "link", "meta", "noframes", "script", "style", "title"</dt>
5287: <dd>
5288: <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
5289: mode</a>.</p>
5290: </dd>
5291:
5292: <dt>A start tag whose tag name is "body"</dt>
5293: <dd>
5294:
5295: <p><a href="#parse-error">Parse error</a>.</p>
5296:
5297: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5298: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5299: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5300: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5301:
5302: <p>Otherwise, for each attribute on the token, check to see if
1.159 mike 5303: the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 5304: element (the second element) on the <a href="#stack-of-open-elements">stack of open
5305: elements</a>. If it is not, add the attribute and its
5306: corresponding value to that element.</p>
5307:
5308: </dd>
5309:
5310: <dt>A start tag whose tag name is "frameset"</dt>
5311: <dd>
5312:
5313: <p><a href="#parse-error">Parse error</a>.</p>
5314:
5315: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5316: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5317: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5318: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5319:
5320: <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
5321: the token.</p>
5322:
5323: <p>Otherwise, run the following steps:</p>
5324:
5325: <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
5326: elements</a> from its parent node, if it has one.</p></li>
5327:
5328: <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
5329: open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159 mike 5330: but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1 mike 5331:
5332: </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
5333: token.</p></li>
5334:
5335: <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>
5336:
5337: </li></ol></dd>
5338:
5339: <dt>An end-of-file token</dt>
5340: <dd>
5341:
5342: <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422 mike 5343: 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>
5344: 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 5345: <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
5346: <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
5347: <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 5348: <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 5349: this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422 mike 5350: fragment cases) -->
1.1 mike 5351:
5352: <p><a href="#stop-parsing">Stop parsing</a>.</p>
5353:
5354: </dd>
5355:
5356: <dt>An end tag whose tag name is "body"</dt>
5357: <dd>
5358:
5359: <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
5360: in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
5361: token.</p>
5362:
5363: <!-- if we get here, the insertion mode here is forcibly "in
5364: body". -->
5365:
5366: <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422 mike 5367: elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1 mike 5368: <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
5369: <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
5370: <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
5371: <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
5372: <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
5373: <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 5374: <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
5375: <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 5376: error</a>.</p> <!-- (some of those are fragment cases, e.g. for
5377: <tbody> you'd have hit the first paragraph since the <body>
1.422 mike 5378: wouldn't be in scope, unless it was a fragment case) -->
1.1 mike 5379:
5380: <!-- If we ever change the frameset-ok flag to an insertion mode,
5381: then we'd have to somehow keep track of its state when we switch
5382: to after-body. -->
5383:
5384: <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>
5385:
5386: </dd>
5387:
5388: <dt>An end tag whose tag name is "html"</dt>
5389: <dd>
5390:
5391: <p>Act as if an end tag with tag name "body" had been seen,
5392: then, if that token wasn't ignored, reprocess the current
5393: token.</p>
5394:
5395: </dd>
5396:
5397: <!-- start tags for non-phrasing flow content elements -->
5398:
5399: <!-- the normal ones -->
5400: <dt>A start tag whose tag name is one of: "address", "article",
1.683 mike 5401: "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305 mike 5402: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5403: "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1 mike 5404: <dd>
5405:
5406: <!-- As of May 2008 this doesn't match any browser exactly, but is
5407: as close to what IE does as I can get without doing the non-tree
5408: DOM nonsense, and thus should actually afford better compatibility
5409: when implemented by the other browsers. -->
5410:
5411: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5412: an element in scope">has a <code>p</code> element in
5413: scope</a>, then act as if an end tag with the tag name
5414: "p" had been seen.</p>
5415:
5416: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5417:
5418: </dd>
5419:
5420: <!-- as normal, but close h1-h6 if it's the current node -->
5421: <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
5422: "h5", "h6"</dt>
5423: <dd>
5424:
5425: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5426: an element in scope">has a <code>p</code> element in
5427: scope</a>, then act as if an end tag with the tag name
5428: "p" had been seen.</p>
5429:
5430: <p>If the <a href="#current-node">current node</a> is an element whose tag name
5431: is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
5432: <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
5433: the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5434: <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
5435:
5436: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5437:
5438: </dd>
5439:
5440: <!-- as normal, but drops leading newline -->
5441: <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
5442: <dd>
5443:
5444: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5445: an element in scope">has a <code>p</code> element in
5446: scope</a>, then act as if an end tag with the tag name
5447: "p" had been seen.</p>
5448:
5449: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5450:
5451: <p>If the next token is a U+000A LINE FEED (LF) character
5452: token, then ignore that token and move on to the next
5453: one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
5454: ignored as an authoring convenience.)</p>
5455:
5456: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5457:
5458: </dd>
5459:
5460: <!-- as normal, but interacts with the form element pointer -->
5461: <dt>A start tag whose tag name is "form"</dt>
5462: <dd>
5463:
5464: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
5465: pointer</a> is not null, then this is a <a href="#parse-error">parse
5466: error</a>; ignore the token.</p>
5467:
5468: <p>Otherwise:</p>
5469:
5470: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5471: an element in scope">has a <code>p</code> element in
5472: scope</a>, then act as if an end tag with the tag name
5473: "p" had been seen.</p>
5474:
5475: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
5476: <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
5477: point to the element created.</p>
5478:
5479: </dd>
5480:
5481: <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
5482: <dt>A start tag whose tag name is "li"</dt>
5483: <dd>
5484:
5485: <p>Run the following algorithm:</p>
5486:
5487: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5488:
5489: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5490: node</a> (the bottommost node of the stack).</p></li>
5491:
1.578 mike 5492: <li><p><i>Loop</i>: If <var title="">node</var> is an
5493: <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
5494: name "li" had been seen, then jump to the last step.</p></li>
1.1 mike 5495:
1.578 mike 5496: <li><p>If <var title="">node</var> is not in the
1.1 mike 5497: <a href="#formatting">formatting</a> category, and is not in the
5498: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5499: <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 5500: element, then jump to the last step.</p></li> <!-- an element
5501: <foo> is in this list if the following markup:
5502:
5503: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
5504:
5505: ...results in the second <li> not being (in any way) a descendant
5506: of the first <li>, or if <foo> is a formatting element that gets
5507: reopened later. -->
5508:
5509: <li><p>Otherwise, set <var title="">node</var> to the previous
5510: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5511: the step labeled <i>loop</i>.</p></li>
5512:
5513: <li>
5514:
5515: <p>This is the last step.</p>
5516:
5517: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5518: an element in scope">has a <code>p</code> element in
5519: scope</a>, then act as if an end tag with the tag name
5520: "p" had been seen.</p>
5521:
5522: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5523: token.</p>
5524:
5525: </li>
5526:
5527: </ol></dd>
5528:
5529: <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases -->
1.422 mike 5530: <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5531: <dd>
5532:
5533: <p>Run the following algorithm:</p>
5534:
5535: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5536:
5537: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5538: node</a> (the bottommost node of the stack).</p></li>
5539:
5540: <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422 mike 5541: <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
5542: tag with the same tag name as <var title="">node</var> had been
5543: seen, then jump to the last step.</p></li>
1.1 mike 5544:
5545: <li><p>If <var title="">node</var> is not in the
5546: <a href="#formatting">formatting</a> category, and is not in the
5547: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5548: <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 5549: element, then jump to the last step.</p></li> <!-- an element
5550: <foo> is in this list if the following markup:
5551:
5552: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
5553:
5554: ...results in the second <dt> not being (in any way) a descendant
5555: of the first <dt>, or if <foo> is a formatting element that gets
5556: reopened later. -->
5557:
5558: <li><p>Otherwise, set <var title="">node</var> to the previous
5559: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5560: the step labeled <i>loop</i>.</p></li>
5561:
5562: <li>
5563:
5564: <p>This is the last step.</p>
5565:
5566: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5567: an element in scope">has a <code>p</code> element in
5568: scope</a>, then act as if an end tag with the tag name
5569: "p" had been seen.</p>
5570:
5571: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5572: token.</p>
5573:
5574: </li>
5575:
5576: </ol></dd>
5577:
5578: <!-- same as normal, but effectively ends parsing -->
5579: <dt>A start tag whose tag name is "plaintext"</dt>
5580: <dd>
5581:
5582: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5583: an element in scope">has a <code>p</code> element in
5584: scope</a>, then act as if an end tag with the tag name
5585: "p" had been seen.</p>
5586:
5587: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5588:
1.541 mike 5589: <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5590:
1.541 mike 5591: <p class="note">Once a start tag with the tag name "plaintext" has
5592: been seen, that will be the last token ever seen other than
5593: character tokens (and the end-of-file token), because there is no
5594: way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5595:
5596: </dd>
5597:
5598: <!-- end tags for non-phrasing flow content elements -->
5599:
5600: <!-- the normal ones -->
5601: <dt>An end tag whose tag name is one of: "address", "article",
1.683 mike 5602: "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305 mike 5603: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5604: "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
5605: "section", "ul"</dt>
1.1 mike 5606: <dd>
5607:
5608: <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>
5609: with the same tag name as that of the token, then this is a
5610: <a href="#parse-error">parse error</a>; ignore the token.</p>
5611:
5612: <p>Otherwise, run these steps:</p>
5613:
5614: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5615:
5616: <li><p>If the <a href="#current-node">current node</a> is not an element with
5617: the same tag name as that of the token, then this is a
5618: <a href="#parse-error">parse error</a>.</p></li>
5619:
5620: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5621: until an element with the same tag name as the token has been
5622: popped from the stack.</p></li>
5623:
5624: </ol></dd>
5625:
5626: <!-- removes the form element pointer instead of the matching node -->
5627: <dt>An end tag whose tag name is "form"</dt>
5628: <dd>
5629:
5630: <p>Let <var title="">node</var> be the element that the
5631: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
5632: to.</p>
5633:
5634: <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
5635: to null.</p>
5636:
5637: <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
5638: elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
5639: scope">have <var title="">node</var> in scope</a>, then this is
5640: a <a href="#parse-error">parse error</a>; ignore the token.</p>
5641:
5642: <p>Otherwise, run these steps:</p>
5643:
5644: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5645:
5646: <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
5647: error</a>.</p></li>
5648:
5649: <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
5650: open elements</a>.</p></li>
5651:
5652: </ol></dd>
5653:
5654: <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
5655: <dt>An end tag whose tag name is "p"</dt>
5656: <dd>
5657:
5658: <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>
5659: with the same tag name as that of the token, then this is a
5660: <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
5661: "p" had been seen, then reprocess the current token.</p>
5662:
5663: <p>Otherwise, run these steps:</p>
5664:
5665: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5666: for elements with the same tag name as the token.</p></li>
5667:
5668: <li><p>If the <a href="#current-node">current node</a> is not an element with
5669: the same tag name as that of the token, then this is a
5670: <a href="#parse-error">parse error</a>.</p></li>
5671:
5672: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5673: until an element with the same tag name as the token has been
5674: popped from the stack.</p></li>
5675:
5676: </ol></dd>
5677:
1.234 mike 5678: <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
5679: <dt>An end tag whose tag name is "li"</dt>
5680: <dd>
5681:
5682: <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
5683: item scope</a> with the same tag name as that of the token,
5684: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5685:
5686: <p>Otherwise, run these steps:</p>
5687:
5688: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5689: for elements with the same tag name as the token.</p></li>
5690:
5691: <li><p>If the <a href="#current-node">current node</a> is not an element with
5692: the same tag name as that of the token, then this is a
5693: <a href="#parse-error">parse error</a>.</p></li>
5694:
5695: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5696: until an element with the same tag name as the token has been
5697: popped from the stack.</p></li>
5698:
5699: </ol></dd>
5700:
1.1 mike 5701: <!-- as normal, but needs care as the elements have optional tags -->
1.422 mike 5702: <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5703: <dd>
5704:
5705: <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>
5706: with the same tag name as that of the token, then this is a
5707: <a href="#parse-error">parse error</a>; ignore the token.</p>
5708:
5709: <p>Otherwise, run these steps:</p>
5710:
5711: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5712: for elements with the same tag name as the token.</p></li>
5713:
5714: <li><p>If the <a href="#current-node">current node</a> is not an element with
5715: the same tag name as that of the token, then this is a
5716: <a href="#parse-error">parse error</a>.</p></li>
5717:
5718: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5719: until an element with the same tag name as the token has been
5720: popped from the stack.</p></li>
5721:
5722: </ol></dd>
5723:
5724: <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
5725: <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
5726: <dd>
5727:
5728: <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>
5729: whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
5730: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5731:
5732: <p>Otherwise, run these steps:</p>
5733:
5734: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5735:
5736: <li><p>If the <a href="#current-node">current node</a> is not an element with
5737: the same tag name as that of the token, then this is a
5738: <a href="#parse-error">parse error</a>.</p></li>
5739:
5740: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5741: until an element whose tag name is one of "h1", "h2", "h3", "h4",
5742: "h5", or "h6" has been popped from the stack.</p></li>
5743:
5744: </ol></dd>
5745:
5746: <dt>An end tag whose tag name is "sarcasm"</dt>
5747: <dd>
5748: <p>Take a deep breath, then act as described in the "any other end
5749: tag" entry below.</p>
5750: </dd>
5751:
5752: <!-- ADOPTION AGENCY ELEMENTS
5753: Mozilla-only: bdo blink del ins sub sup q
5754: Safari-only: code dfn kbd nobr samp var wbr
5755: Both: a b big em font i s small strike strong tt u -->
5756:
5757: <dt>A start tag whose tag name is "a"</dt>
5758: <dd>
5759:
5760: <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
5761: contains an element whose tag name is "a" between the end of
5762: the list and the last marker on the list (or the start of the
5763: list if there is no marker on the list), then this is a
5764: <a href="#parse-error">parse error</a>; act as if an end tag with the tag
5765: name "a" had been seen, then remove that element from the
5766: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
5767: <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
5768: already remove it (it might not have if the element is not
5769: <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
5770: scope</a>).</p>
5771:
5772: <p class="example">In the non-conforming stream
5773: <code><a href="a">a<table><a href="b">b</table>x</code>,
5774: the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing
5775: the second one, and the "x" character would be inside a link
5776: to "b", not to "a". This is despite the fact that the outer
5777: <code><a href="text-level-semantics.html#the-a-element">a</a></code> element is not in table scope (meaning that a
5778: regular <code></a></code> end tag at the start of the table
5779: wouldn't close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element).</p>
5780:
5781: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5782: any.</p>
5783:
5784: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5785: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5786: elements</a>.</p>
5787:
5788: </dd>
5789:
5790: <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
5791: "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
5792: <dd>
5793:
5794: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5795: any.</p>
5796:
5797: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5798: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5799: elements</a>.</p>
5800:
5801: </dd>
5802:
5803: <dt>A start tag whose tag name is "nobr"</dt>
5804: <dd>
5805:
5806: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5807: any.</p>
5808:
5809: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
5810: element in scope">has a <code>nobr</code> element in scope</a>,
5811: then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
5812: the tag name "nobr" had been seen, then once again
5813: <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
5814: any.</p>
5815:
5816: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5817: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5818: elements</a>.</p>
5819:
5820: </dd>
5821:
5822: <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
5823: "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
5824: "strike", "strong", "tt", "u"</dt>
5825: <dd>
5826:
5827: <p>Follow these steps:</p>
5828:
5829: <ol><li>
5830:
5831: <p>Let the <var title="">formatting element</var> be the
5832: last element in the <a href="#list-of-active-formatting-elements">list of active formatting
5833: elements</a> that:</p>
5834:
5835: <ul><li>is between the end of the list and the last scope
5836: marker in the list, if any, or the start of the list
5837: otherwise, and</li>
5838:
5839: <li>has the same tag name as the token.</li>
5840:
5841: </ul><p>If there is no such node, or, if that node is also in the
5842: <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
5843: <a href="#parse-error">parse error</a>; ignore the token, and abort these
5844: steps.</p>
5845:
5846: <p>Otherwise, if there is such a node, but that node is not
5847: in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
5848: <a href="#parse-error">parse error</a>; remove the element from the list,
5849: and abort these steps.</p>
5850:
5851: <p>Otherwise, there is a <var title="">formatting
5852: element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
5853: open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
5854: element in scope">in scope</a>. If the element is not the
5855: <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
5856: error</a>. In any case, proceed with the algorithm as
5857: written in the following steps.</p>
5858:
5859: </li>
5860:
5861: <li><p>Let the <var title="">furthest block</var> be the
5862: topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
5863: is lower in the stack than the <var title="">formatting
5864: element</var>, and is not an element in the
5865: <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
5866: categories. There might not be one.</p></li>
5867:
5868: <li><p>If there is no <var title="">furthest block</var>,
5869: then the UA must skip the subsequent steps and instead just
5870: pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
5871: elements</a>, from the <a href="#current-node">current node</a> up to and
5872: including the <var title="">formatting element</var>, and
5873: remove the <var title="">formatting element</var> from the
5874: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
5875:
5876: <li><p>Let the <var title="">common ancestor</var> be the element
5877: immediately above the <var title="">formatting element</var> in the
5878: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
5879:
5880: <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
5881: formatting elements</a> relative to the elements on either
5882: side of it in the list.</p></li>
5883:
5884: <li>
5885:
5886: <p>Let <var title="">node</var> and <var title="">last node</var> be the
5887: <var title="">furthest block</var>. Follow these steps:</p>
5888:
5889: <ol><li>Let <var title="">node</var> be the element immediately
5890: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436 mike 5891: elements</a>, or if <var title="">node</var> is no longer in
5892: the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
5893: removed by the next step), the element that was immediately
5894: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
5895: elements</a> before <var title="">node</var> was
5896: removed.</li>
1.1 mike 5897:
5898: <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
5899: active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
5900: elements</a> and then go back to step 1.</li>
5901:
5902: <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
5903: in the overall algorithm.</li>
5904:
5905: <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
5906: bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
5907: elements</a>.</li>
5908:
5909: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
5910: element <var title="">node</var> was created, replace the entry
5911: for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
5912: formatting elements</a> with an entry for the new element,
5913: replace the entry for <var title="">node</var> in the
5914: <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
5915: element, and let <var title="">node</var> be the new
5916: element.</li>
5917:
5918: <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
5919: parent node if any.</li>
5920:
5921: <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
5922:
5923: <li>Return to step 1 of this inner set of steps.</li>
5924:
5925: </ol></li>
5926:
5927: <li>
5928:
5929: <p>If the <var title="">common ancestor</var> node is a
5930: <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>,
5931: <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,
5932: <a href="#foster-parent">foster parent</a> whatever <var title="">last
5933: node</var> ended up being in the previous step, first removing
5934: it from its previous parent node if any.</p>
5935:
5936: <p>Otherwise, append whatever <var title="">last node</var>
5937: ended up being in the previous step to the <var title="">common
5938: ancestor</var> node, first removing it from its previous parent
5939: node if any.</p>
5940:
5941: </li>
5942:
5943: <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
5944: <var title="">formatting element</var> was created.</p></li>
5945:
5946: <li><p>Take all of the child nodes of the <var title="">furthest
5947: block</var> and append them to the element created in the last
5948: step.</p></li>
5949:
5950: <li><p>Append that new element to the <var title="">furthest
5951: block</var>.</p></li>
5952:
5953: <li><p>Remove the <var title="">formatting element</var> from the
5954: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
5955: new element into the <a href="#list-of-active-formatting-elements">list of active formatting
5956: elements</a> at the position of the aforementioned
5957: bookmark.</p></li>
5958:
5959: <li><p>Remove the <var title="">formatting element</var> from the
5960: <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
5961: into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
5962: the position of the <var title="">furthest block</var> in that
5963: stack.</p></li>
5964:
5965: <li><p>Jump back to step 1 in this series of steps.</p></li>
5966:
1.334 mike 5967: </ol><p class="note">Because of the way this algorithm causes elements
1.304 mike 5968: to change parents, it has been dubbed the "adoption agency
5969: algorithm" (in contrast with other possible algorithms for dealing
5970: with misnested content, which included the "incest algorithm", the
1.1 mike 5971: "secret affair algorithm", and the "Heisenberg algorithm").</p>
5972:
5973: </dd>
5974:
5975: <dt>A start tag whose tag name is "button"</dt>
5976: <dd>
5977:
5978: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5979: an element in scope">has a <code>button</code> element in
5980: scope</a>, then this is a <a href="#parse-error">parse error</a>;
5981: act as if an end tag with the tag name "button" had been seen,
5982: then reprocess the token.</p>
5983:
5984: <p>Otherwise:</p>
5985:
5986: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5987: any.</p>
5988:
5989: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5990:
5991: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
5992: formatting elements</a>.</p>
5993:
5994: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5995:
5996: </dd>
5997:
5998: <dt>A start tag token whose tag name is one of: "applet",
5999: "marquee", "object"</dt>
6000: <dd>
6001:
6002: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6003: any.</p>
6004:
6005: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6006:
6007: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6008: formatting elements</a>.</p>
6009:
6010: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6011:
6012: </dd>
6013:
6014: <dt>An end tag token whose tag name is one of: "applet", "button",
6015: "marquee", "object"</dt>
6016: <dd>
6017:
6018: <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>
6019: with the same tag name as that of the token, then this is a
6020: <a href="#parse-error">parse error</a>; ignore the token.</p>
6021:
6022: <p>Otherwise, run these steps:</p>
6023:
6024: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6025:
6026: <li><p>If the <a href="#current-node">current node</a> is not an element with
6027: the same tag name as that of the token, then this is a
6028: <a href="#parse-error">parse error</a>.</p></li>
6029:
6030: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
6031: until an element with the same tag name as the token has been
6032: popped from the stack.</p></li>
6033:
6034: <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
6035: last marker</a>.</li>
6036:
6037: </ol></dd>
6038:
6039: <dt>A start tag whose tag name is "table"</dt>
6040: <dd>
6041:
1.810 mike 6042: <p>If the <code><a href="infrastructure.html#document">Document</a></code> is <em>not</em> set to
1.1 mike 6043: <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
6044: elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
6045: <code>p</code> element in scope</a>, then act as if an end tag
6046: with the tag name "p" had been seen.</p> <!-- i hate myself (this
6047: quirk was basically caused by acid2; if i'd realised we could
6048: change the specs when i wrote acid2, we could have avoided having
6049: any parsing-mode quirks) -Hixie -->
6050:
6051: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6052:
6053: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6054:
6055: <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>
6056:
6057: </dd>
6058:
6059: <dt>A start tag whose tag name is one of: "area", "basefont",
1.589 mike 6060: "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1 mike 6061: <dd>
6062:
6063: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6064: any.</p>
6065:
6066: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6067: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6068: elements</a>.</p>
6069:
6070: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6071: token's <i>self-closing flag</i></a>, if it is set.</p>
6072:
6073: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589 mike 6074: shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1 mike 6075:
6076: </dd>
6077:
6078: <dt>A start tag whose tag name is one of: "param", "source"</dt>
6079: <dd>
6080:
6081: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6082: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6083: elements</a>.</p>
6084:
6085: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6086: token's <i>self-closing flag</i></a>, if it is set.</p>
6087:
6088: </dd>
6089:
6090: <dt>A start tag whose tag name is "hr"</dt>
6091: <dd>
6092:
6093: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6094: an element in scope">has a <code>p</code> element in
6095: scope</a>, then act as if an end tag with the tag name
6096: "p" had been seen.</p>
6097:
6098: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6099: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6100: elements</a>.</p>
6101:
6102: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6103: token's <i>self-closing flag</i></a>, if it is set.</p>
6104:
6105: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6106:
6107: </dd>
6108:
6109: <dt>A start tag whose tag name is "image"</dt>
6110: <dd>
6111: <p><a href="#parse-error">Parse error</a>. Change the token's tag name
6112: to "img" and reprocess it. (Don't ask.)</p> <!-- As of
6113: 2005-12, studies showed that around 0.2% of pages used the
6114: <image> element. -->
6115: </dd>
6116:
6117: <dt id="isindex">A start tag whose tag name is "isindex"</dt>
6118: <dd>
6119:
6120: <p><a href="#parse-error">Parse error</a>.</p>
6121:
6122: <p>If the <a href="#form-element-pointer"><code title="">form</code> element
6123: pointer</a> is not null, then ignore the token.</p>
6124:
6125: <p>Otherwise:</p>
6126:
6127: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6128: token's <i>self-closing flag</i></a>, if it is set.</p> <!--
6129: purely to reduce the number of errors (we don't care if they
6130: included the /, they're not supposed to be including the tag at
6131: all! -->
6132:
6133: <p>Act as if a start tag token with the tag name "form" had been seen.</p>
6134:
6135: <p>If the token has an attribute called "action", set the
6136: <code title="attr-form-action">action</code> attribute on the
6137: resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
6138: "action" attribute of the token.</p>
6139:
6140: <p>Act as if a start tag token with the tag name "hr" had been
6141: seen.</p>
6142:
6143: <p>Act as if a start tag token with the tag name "label" had been
6144: seen.</p>
6145:
6146: <p>Act as if a stream of character tokens had been seen (see below
6147: for what they should say).</p>
6148:
6149: <p>Act as if a start tag token with the tag name "input" had been
6150: seen, with all the attributes from the "isindex" token except
6151: "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
6152: <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
6153:
6154: <p>Act as if a stream of character tokens had been seen (see
6155: below for what they should say).</p>
6156:
6157: <p>Act as if an end tag token with the tag name "label" had been
6158: seen.</p>
6159:
6160: <p>Act as if a start tag token with the tag name "hr" had been
6161: seen.</p>
6162:
6163: <p>Act as if an end tag token with the tag name "form" had been
6164: seen.</p>
6165:
6166: <p>If the token has an attribute with the name "prompt", then the
6167: first stream of characters must be the same string as given in
6168: that attribute, and the second stream of characters must be
6169: empty. Otherwise, the two streams of character tokens together
6170: should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
6171: equivalent of "This is a searchable index. Insert your search
6172: keywords here: (input field)" in the user's preferred
6173: language.</p>
6174:
6175: </dd>
6176:
6177: <dt>A start tag whose tag name is "textarea"</dt>
6178: <dd>
6179:
6180: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
6181: token.</p></li>
6182:
6183: <li><p>If the next token is a U+000A LINE FEED (LF) character
6184: token, then ignore that token and move on to the next
6185: one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
6186: ignored as an authoring convenience.)</p></li>
6187:
1.671 mike 6188: <li><p>Switch the tokenizer to the <a href="#rcdata-state">RCDATA
1.541 mike 6189: state</a>.</p></li>
1.1 mike 6190:
6191: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
6192: current <a href="#insertion-mode">insertion mode</a>.</p>
6193:
6194: </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
6195: ok".</p></li>
6196:
1.540 mike 6197: <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 6198:
6199: </ol></dd>
6200:
6201: <dt>A start tag whose tag name is "xmp"</dt>
6202: <dd>
6203:
1.233 mike 6204: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6205: an element in scope">has a <code>p</code> element in
6206: scope</a>, then act as if an end tag with the tag name
6207: "p" had been seen.</p>
6208:
1.1 mike 6209: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6210: any.</p>
6211:
6212: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6213:
1.91 mike 6214: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6215:
6216: </dd>
6217:
6218: <dt>A start tag whose tag name is "iframe"</dt>
6219: <dd>
6220:
6221: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6222:
1.91 mike 6223: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6224:
6225: </dd>
6226:
6227: <dt>A start tag whose tag name is "noembed"</dt>
6228: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
6229: <dd>
6230:
1.91 mike 6231: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6232:
6233: </dd>
6234:
6235: <dt>A start tag whose tag name is "select"</dt>
6236: <dd>
6237:
6238: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6239: any.</p>
6240:
6241: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6242:
6243: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6244:
6245: <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>",
6246: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6247: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
6248: row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
6249: cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
6250: "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
6251: table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
6252: to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
6253:
6254: </dd>
6255:
6256: <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
6257: <dd>
6258:
6259: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6260: element in scope">has an <code>option</code> element in
6261: scope</a>, then act as if an end tag with the tag name "option"
6262: had been seen.</p>
6263:
6264: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6265: any.</p>
6266:
6267: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6268:
6269: </dd>
6270:
6271: <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
6272: <dd>
6273:
6274: <!-- the parsing rules for ruby really don't match IE much at all,
6275: but in practice the markup used is very simple and so strict
6276: compatibility with IE isn't required. For example, as defined
6277: here we get very, very different behaviour than IE for
6278: pathological cases like:
6279:
6280: <ruby><ol><li><p>a<rt>b
6281: <ruby>a<rt>b<p>c
6282:
6283: But in practice most ruby markup falls into these cases:
6284:
6285: <ruby>a<rt>b</ruby>
6286: <ruby>a<rp>b<rt>c<rp>d</ruby>
6287: <ruby>a<rt>b</rt></ruby>
6288: <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
6289:
6290: -->
6291:
6292: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6293: element in scope">has a <code>ruby</code> element in scope</a>,
6294: then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
6295: node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
6296: <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
6297: node</a> up to the node immediately before the bottommost
6298: <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
6299: elements</a>.</p>
6300:
6301: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6302:
6303: </dd>
6304:
6305: <dt>An end tag whose tag name is "br"</dt>
6306: <dd>
6307: <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
6308: the tag name "br" had been seen. Ignore the end tag token.</p>
6309: </dd>
6310:
6311: <dt>A start tag whose tag name is "math"</dt>
6312: <dd>
6313:
6314: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6315: any.</p>
6316:
6317: <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
6318: fixes the case of MathML attributes that are not all
6319: lowercase.)</p>
6320:
6321: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6322: fixes the use of namespaced attributes, in particular XLink.)</p>
6323:
6324: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724 mike 6325: <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</p>
1.1 mike 6326:
6327: <!-- If we ever change the frameset-ok flag to an insertion mode,
6328: the following change would be implied, except we'd have to do it
6329: even in the face of a self-closed tag:
6330: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6331: -->
6332:
6333: <p>If the token has its <i>self-closing flag</i> set, pop the
6334: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6335: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6336: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6337:
6338: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6339: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6340: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6341: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6342: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6343: foreign content">in foreign content</a>".</p>
6344:
6345: </dd>
6346:
6347: <dt>A start tag whose tag name is "svg"</dt>
6348: <dd>
6349:
6350: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6351: any.</p>
6352:
6353: <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
6354: the case of SVG attributes that are not all lowercase.)</p>
6355:
6356: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6357: fixes the use of namespaced attributes, in particular XLink in
6358: SVG.)</p>
6359:
6360: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724 mike 6361: <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</p>
1.1 mike 6362:
6363: <!-- If we ever change the frameset-ok flag to an insertion mode,
6364: the following change would be implied, except we'd have to do it
6365: even in the face of a self-closed tag:
6366: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6367: -->
6368:
6369: <p>If the token has its <i>self-closing flag</i> set, pop the
6370: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6371: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6372: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6373:
6374: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6375: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6376: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6377: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6378: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6379: foreign content">in foreign content</a>".</p>
6380:
6381: </dd>
6382:
6383: <dt>A start <!--or end--> tag whose tag name is one of: "caption",
6384: "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
6385: "thead", "tr"</dt>
6386: <!--<dt>An end tag whose tag name is one of: "area", "base",
6387: "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
6388: "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589 mike 6389: "noframes", "param", "script", "select", "source", "style",
6390: "table", "textarea", "title", "wbr"</dt>-->
1.1 mike 6391: <!--<dt>An end tag whose tag name is "noscript", if the
6392: <span>scripting flag</span> is enabled</dt>-->
6393: <dd>
6394: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6395: <!-- end tags are commented out because since they can never end
6396: up on the stack anyway, the default end tag clause will
6397: automatically handle them. we don't want to have text in the spec
6398: that is just an optimisation, as that detracts from the spec
6399: itself -->
6400: </dd>
6401:
6402: <dt>Any other start tag</dt>
6403: <dd>
6404:
6405: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6406: any.</p>
6407:
6408: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6409:
6410: <p class="note">This element will be a <a href="#phrasing">phrasing</a>
6411: element.</p>
6412:
6413: </dd>
6414:
6415: <dt>Any other end tag</dt>
6416: <dd>
6417:
6418: <p>Run the following steps:</p>
6419:
6420: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
6421: node</a> (the bottommost node of the stack).</p></li>
6422:
6423: <li><p>If <var title="">node</var> has the same tag name as
6424: the end tag token, then:</p>
6425:
6426: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6427:
6428: <li><p>If the tag name of the end tag token does not match
6429: the tag name of the <a href="#current-node">current node</a>, this is a
6430: <a href="#parse-error">parse error</a>.</p></li>
6431:
6432: <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
6433: to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
6434:
6435: </ol></li>
6436:
6437: <li><p>Otherwise, if <var title="">node</var> is in neither the
6438: <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
6439: category, then this is a <a href="#parse-error">parse error</a>; ignore the
6440: token, and abort these steps.</p></li>
6441:
6442: <li><p>Set <var title="">node</var> to the previous entry in the
6443: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
6444:
6445: <li><p>Return to step 2.</p></li>
6446:
6447: </ol></dd>
6448:
1.755 mike 6449: </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 6450:
6451: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540 mike 6452: mode: text">text</a>", tokens must be handled as follows:</p>
1.1 mike 6453:
6454: <dl class="switch"><dt>A character token</dt>
6455: <dd>
6456:
6457: <p><a href="#insert-a-character" title="insert a character">Insert the token's
6458: character</a> into the <a href="#current-node">current node</a>.</p>
6459:
6460: </dd>
6461:
6462: <dt>An end-of-file token</dt>
6463: <dd>
6464:
6465: <!-- can't be the fragment case -->
6466: <p><a href="#parse-error">Parse error</a>.</p>
6467:
6468: <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484 mike 6469: element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
6470: started"</a>.</p>
1.1 mike 6471:
6472: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6473: elements</a>.</p>
6474:
6475: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6476: insertion mode</a> and reprocess the current token.</p>
6477:
6478: </dd>
6479:
6480: <dt>An end tag whose tag name is "script"</dt>
6481: <dd>
6482:
6483: <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
6484: (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
6485:
6486: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6487: elements</a>.</p>
6488:
6489: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6490: insertion mode</a>.</p>
6491:
6492: <p>Let the <var title="">old insertion point</var> have the
6493: same value as the current <a href="#insertion-point">insertion point</a>. Let
6494: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
6495: input character</a>.</p>
6496:
6497: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
6498: one.</p>
6499:
6500: <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 6501: which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1 mike 6502: to be inserted into the tokenizer</a>, and might cause the
6503: tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
6504:
6505: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
6506: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
6507: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6508:
6509: <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
6510: <a href="#insertion-point">insertion point</a> to its previous value. This value
6511: might be the "undefined" value.)</p>
6512:
6513: <p id="scriptTagParserResumes">At this stage, if there is a
1.484 mike 6514: <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1 mike 6515:
6516: <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
6517:
6518: <dd>
6519:
6520: <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
6521: processing of any nested invocations of the tokenizer, yielding
6522: control back to the caller. (Tokenization will resume when the
6523: caller returns to the "outer" tree construction stage.)</p>
6524:
6525: <p class="note">The tree construction stage of this particular
6526: parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159 mike 6527: 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 6528:
6529: </dd>
6530:
6531:
6532: <dt>Otherwise:</dt>
6533:
6534: <dd>
6535:
6536: <p>Follow these steps:</p>
6537:
1.484 mike 6538: <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
6539: parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
6540: parsing-blocking script</a>.</p></li>
6541:
6542: <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
6543: for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794 mike 6544: 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 6545:
1.794 mike 6546: <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 6547: scripts</a> and <var title="">the script</var>'s
6548: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
6549:
6550: <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
6551: for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794 mike 6552: <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 6553: run.</p></li>
1.1 mike 6554:
6555: <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
6556: <a href="#next-input-character">next input character</a>.</p></li>
6557:
6558: <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
6559: by one (it should be zero before this step, so this sets it to
6560: one).</p></li>
6561:
1.484 mike 6562: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
6563: <var title="">the script</var>.</p></li>
1.1 mike 6564:
6565: <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
6566: by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
6567: zero (which it always should be at this point), then set the
6568: <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6569:
6570: </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
6571: again.</p></li>
6572:
1.484 mike 6573: <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1 mike 6574: script</a>, then repeat these steps from step 1.</p></li>
6575:
6576: </ol></dd>
6577:
6578: </dl></dd>
6579:
6580: <dt>Any other end tag</dt>
6581: <dd>
6582:
6583: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6584: elements</a>.</p>
6585:
6586: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6587: insertion mode</a>.</p>
6588:
6589: </dd>
6590:
1.755 mike 6591: </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 6592:
6593: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
6594: mode: in table">in table</a>", tokens must be handled as follows:</p>
6595:
6596: <dl class="switch"><dt>A character token</dt>
6597: <dd>
6598:
6599: <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
6600: be an empty list of tokens.</p>
6601:
6602: <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
6603: <a href="#insertion-mode">insertion mode</a>.</p>
6604:
6605: <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
6606: reprocess the token.</p>
6607:
6608: </dd>
6609:
6610: <dt>A comment token</dt>
6611: <dd>
6612: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
6613: node</a> with the <code title="">data</code> attribute set to
6614: the data given in the comment token.</p>
6615: </dd>
6616:
6617: <dt>A DOCTYPE token</dt>
6618: <dd>
6619: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6620: </dd>
6621:
6622: <dt>A start tag whose tag name is "caption"</dt>
6623: <dd>
6624:
6625: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6626: below.)</p>
6627:
6628: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6629: formatting elements</a>.</p>
6630:
6631: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6632: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
6633:
6634: </dd>
6635:
6636: <dt>A start tag whose tag name is "colgroup"</dt>
6637: <dd>
6638:
6639: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6640: below.)</p>
6641:
6642: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6643: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
6644: group</a>".</p>
6645:
6646: </dd>
6647:
6648: <dt>A start tag whose tag name is "col"</dt>
6649: <dd>
6650: <p>Act as if a start tag token with the tag name "colgroup"
6651: had been seen, then reprocess the current token.</p>
6652: </dd>
6653:
6654: <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
6655: <dd>
6656:
6657: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6658: below.)</p>
6659:
6660: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6661: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6662: body</a>".</p>
6663:
6664: </dd>
6665:
6666: <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
6667: <dd>
6668: <p>Act as if a start tag token with the tag name "tbody" had
6669: been seen, then reprocess the current token.</p>
6670: </dd>
6671:
6672: <dt>A start tag whose tag name is "table"</dt>
6673: <dd>
6674:
6675: <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
6676: the tag name "table" had been seen, then, if that token wasn't
6677: ignored, reprocess the current token.</p>
6678:
6679: <p class="note">The fake end tag token here can only be
6680: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6681:
6682: </dd>
6683:
6684: <dt>An end tag whose tag name is "table"</dt>
6685: <dd>
6686:
6687: <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
6688: scope</a> with the same tag name as the token, this is a
6689: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6690: case</a>)</p>
6691:
6692: <p>Otherwise:</p>
6693:
6694: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
6695: element has been popped from the stack.</p>
6696:
6697: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
6698:
6699: </dd>
6700:
6701: <dt>An end tag whose tag name is one of: "body", "caption",
6702: "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
6703: "thead", "tr"</dt>
6704: <dd>
6705: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6706: </dd>
6707:
6708: <dt>A start tag whose tag name is one of: "style", "script"</dt>
6709: <dd>
6710:
6711: <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
6712: mode</a>.</p>
6713:
6714: </dd>
6715:
6716: <dt>A start tag whose tag name is "input"</dt>
6717: <dd>
6718:
6719: <p>If the token does not have an attribute with the name "type",
6720: or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
6721: case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
6722: else" entry below.</p>
6723:
6724: <p>Otherwise:</p>
6725:
6726: <p><a href="#parse-error">Parse error</a>.</p>
6727:
6728: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6729:
6730: <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
6731: open elements</a>.</p>
6732:
6733: </dd>
6734:
1.603 mike 6735: <dt>A start tag whose tag name is "form"</dt>
6736: <dd>
6737:
6738: <p><a href="#parse-error">Parse error</a>.</p>
6739:
1.717 mike 6740: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
6741: pointer</a> is not null, ignore the token.</p>
6742:
6743: <p>Otherwise:</p>
6744:
1.603 mike 6745: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6746:
1.637 mike 6747: <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 6748: open elements</a>.</p>
6749:
6750: </dd>
6751:
1.721 mike 6752: <!-- "form" end tag falls through to in-body, which does the right thing -->
1.717 mike 6753:
1.1 mike 6754: <dt>An end-of-file token</dt>
6755: <dd>
6756:
6757: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 6758: <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 6759: error</a>.</p>
6760:
6761: <p class="note">It can only be the <a href="#current-node">current node</a> in
6762: the <a href="#fragment-case">fragment case</a>.</p>
6763:
6764: <p><a href="#stop-parsing">Stop parsing</a>.</p>
6765:
6766: </dd>
6767:
6768: <dt>Anything else</dt>
6769: <dd>
6770:
6771: <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
6772: rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
6773: body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
6774: <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
6775: <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
6776: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
6777: into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
6778:
6779: </dd>
6780:
6781: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
6782: back to a table context</dfn>, it means that the UA must, while
6783: 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 6784: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 6785: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
6786:
6787: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 6788: <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 6789: case</a>.</p>
6790:
6791:
6792:
1.755 mike 6793: <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 6794:
6795: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
6796: mode: in table text">in table text</a>", tokens must be handled
6797: as follows:</p>
6798:
6799: <dl class="switch"><dt>A character token</dt>
6800: <dd>
6801:
6802: <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
6803: tokens</a></var> list.</p>
6804:
6805: </dd>
6806:
6807:
6808: <dt>Anything else</dt>
6809: <dd>
6810:
6811: <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
6812: tokens</a></var> list are character tokens that are not one of U+0009
6813: CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
6814: (FF), <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE, then
6815: reprocess those character tokens using the rules given in the
6816: "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
6817: table">in table</a>" insertion mode.</p>
6818:
6819: <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
6820: characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
6821: tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
6822:
6823: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6824: insertion mode</a> and reprocess the token.</p>
6825:
6826: </dd>
6827:
1.755 mike 6828: </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 6829:
6830: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
6831: mode: in caption">in caption</a>", tokens must be handled as follows:</p>
6832:
6833: <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
6834: <dd>
6835:
6836: <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
6837: scope</a> with the same tag name as the token, this is a
6838: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6839: case</a>)</p>
6840:
6841: <p>Otherwise:</p>
6842:
6843: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
6844:
6845: <p>Now, if the <a href="#current-node">current node</a> is not a
6846: <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
6847: error</a>.</p>
6848:
6849: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
6850: element has been popped from the stack.</p>
6851:
6852: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
6853: the last marker</a>.</p>
6854:
6855: <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>
6856:
6857: </dd>
6858:
6859: <dt>A start tag whose tag name is one of: "caption", "col",
6860: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
6861: <dt>An end tag whose tag name is "table"</dt>
6862: <dd>
6863:
6864: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
6865: name "caption" had been seen, then, if that token wasn't
6866: ignored, reprocess the current token.</p>
6867:
6868: <p class="note">The fake end tag token here can only be
6869: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6870:
6871: </dd>
6872:
6873: <dt>An end tag whose tag name is one of: "body", "col",
6874: "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
6875: "tr"</dt>
6876: <dd>
6877: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6878: </dd>
6879:
6880: <dt>Anything else</dt>
6881: <dd>
6882: <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
6883: mode</a>.</p>
6884: </dd>
6885:
1.755 mike 6886: </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 6887:
6888: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
6889: mode: in column group">in column group</a>", tokens must be handled as follows:</p>
6890:
6891: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
6892: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
6893: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
6894: <dd>
6895: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
6896: the <a href="#current-node">current node</a>.</p>
6897: </dd>
6898:
6899: <dt>A comment token</dt>
6900: <dd>
6901: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
6902: node</a> with the <code title="">data</code> attribute set to
6903: the data given in the comment token.</p>
6904: </dd>
6905:
6906: <dt>A DOCTYPE token</dt>
6907: <dd>
6908: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6909: </dd>
6910:
6911: <dt>A start tag whose tag name is "html"</dt>
6912: <dd>
6913: <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
6914: mode</a>.</p>
6915: </dd>
6916:
6917: <dt>A start tag whose tag name is "col"</dt>
6918: <dd>
6919:
6920: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6921: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6922: elements</a>.</p>
6923:
6924: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6925: token's <i>self-closing flag</i></a>, if it is set.</p>
6926:
6927: </dd>
6928:
6929: <dt>An end tag whose tag name is "colgroup"</dt>
6930: <dd>
6931:
6932: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 6933: <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 6934: error</a>; ignore the token. (<a href="#fragment-case">fragment
6935: case</a>)</p>
6936:
6937: <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
6938: 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
6939: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
6940: "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
6941:
6942: </dd>
6943:
6944: <dt>An end tag whose tag name is "col"</dt>
6945: <dd>
6946: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6947: </dd>
6948:
6949: <dt>An end-of-file token</dt>
6950: <dd>
6951:
1.159 mike 6952: <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 6953: element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
6954: case</a>)</p>
6955:
6956: <p>Otherwise, act as described in the "anything else" entry
6957: below.</p>
6958:
6959: </dd>
6960:
6961: <dt>Anything else</dt>
6962: <dd>
6963:
6964: <p>Act as if an end tag with the tag name "colgroup" had been
6965: seen, and then, if that token wasn't ignored, reprocess the
6966: current token.</p>
6967:
6968: <p class="note">The fake end tag token here can only be
6969: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6970:
6971: </dd>
6972:
1.755 mike 6973: </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 6974:
6975: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
6976: mode: in table body">in table body</a>", tokens must be handled as follows:</p>
6977:
6978: <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
6979: <dd>
6980:
6981: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
6982: context</a>. (See below.)</p>
6983:
6984: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
6985: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
6986: in row">in row</a>".</p>
6987:
6988: </dd>
6989:
6990: <dt>A start tag whose tag name is one of: "th", "td"</dt>
6991: <dd>
6992: <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
6993: the tag name "tr" had been seen, then reprocess the current
6994: token.</p>
6995: </dd>
6996:
6997: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
6998: "thead"</dt>
6999: <dd>
7000:
7001: <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
7002: scope</a> with the same tag name as the token, this is a
7003: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7004:
7005: <p>Otherwise:</p>
7006:
7007: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7008: context</a>. (See below.)</p>
7009:
7010: <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
7011: open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7012: to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
7013:
7014: </dd>
7015:
7016: <dt>A start tag whose tag name is one of: "caption", "col",
7017: "colgroup", "tbody", "tfoot", "thead"</dt>
7018: <dt>An end tag whose tag name is "table"</dt>
7019: <dd>
7020:
7021: <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
7022: <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
7023: element in table scope</a>, this is a <a href="#parse-error">parse
7024: error</a>. Ignore the token. (<a href="#fragment-case">fragment
7025: case</a>)</p>
7026:
7027: <p>Otherwise:</p>
7028:
7029: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7030: context</a>. (See below.)</p>
7031:
7032: <p>Act as if an end tag with the same tag name as the
7033: <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
7034: been seen, then reprocess the current token.</p>
7035:
7036: </dd>
7037:
7038: <dt>An end tag whose tag name is one of: "body", "caption",
7039: "col", "colgroup", "html", "td", "th", "tr"</dt>
7040: <dd>
7041: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7042: </dd>
7043:
7044: <dt>Anything else</dt>
7045: <dd>
7046: <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
7047: mode</a>.</p>
7048: </dd>
7049:
7050: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
7051: back to a table body context</dfn>, it means that the UA must,
7052: 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 7053: <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 7054: element, pop elements from the <a href="#stack-of-open-elements">stack of open
7055: elements</a>.</p>
7056:
7057: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 7058: <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 7059: case</a>.</p>
7060:
7061:
1.755 mike 7062: <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 7063:
7064: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
7065: mode: in row">in row</a>", tokens must be handled as follows:</p>
7066:
7067: <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
7068: <dd>
7069:
7070: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7071: context</a>. (See below.)</p>
7072:
7073: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
7074: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
7075: in cell">in cell</a>".</p>
7076:
7077: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
7078: formatting elements</a>.</p>
7079:
7080: </dd>
7081:
7082: <dt>An end tag whose tag name is "tr"</dt>
7083: <dd>
7084:
7085: <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
7086: scope</a> with the same tag name as the token, this is a
7087: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7088: case</a>)</p>
7089:
7090: <p>Otherwise:</p>
7091:
7092: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7093: context</a>. (See below.)</p>
7094:
7095: <p>Pop the <a href="#current-node">current node</a> (which will be a
7096: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
7097: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
7098: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
7099: body</a>".</p>
7100:
7101: </dd>
7102:
7103: <dt>A start tag whose tag name is one of: "caption", "col",
7104: "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
7105: <dt>An end tag whose tag name is "table"</dt>
7106: <dd>
7107:
7108: <p>Act as if an end tag with the tag name "tr" had been seen,
7109: then, if that token wasn't ignored, reprocess the current
7110: token.</p>
7111:
7112: <p class="note">The fake end tag token here can only be
7113: ignored in the <a href="#fragment-case">fragment case</a>.</p>
7114:
7115: </dd>
7116:
7117: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
7118: "thead"</dt>
7119: <dd>
7120:
7121: <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
7122: scope</a> with the same tag name as the token, this is a
7123: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7124:
7125: <p>Otherwise, act as if an end tag with the tag name "tr" had
7126: been seen, then reprocess the current token.</p>
7127:
7128: </dd>
7129:
7130: <dt>An end tag whose tag name is one of: "body", "caption",
7131: "col", "colgroup", "html", "td", "th"</dt>
7132: <dd>
7133: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7134: </dd>
7135:
7136: <dt>Anything else</dt>
7137: <dd>
7138: <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
7139: mode</a>.</p>
7140: </dd>
7141:
7142: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
7143: back to a table row context</dfn>, it means that the UA must,
7144: 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 7145: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 7146: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7147:
7148: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 7149: <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 7150: case</a>.</p>
7151:
7152:
1.755 mike 7153: <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 7154:
7155: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
7156: mode: in cell">in cell</a>", tokens must be handled as follows:</p>
7157:
7158: <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
7159: <dd>
7160:
7161: <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
7162: scope</a> with the same tag name as that of the token, then
7163: this is a <a href="#parse-error">parse error</a> and the token must be
7164: ignored.</p>
7165:
7166: <p>Otherwise:</p>
7167:
7168: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
7169:
7170: <p>Now, if the <a href="#current-node">current node</a> is not an element
7171: with the same tag name as the token, then this is a
7172: <a href="#parse-error">parse error</a>.</p>
7173:
7174: <p>Pop elements from this stack until an element with the same
7175: tag name as the token has been popped from the stack.</p>
7176:
7177: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
7178: the last marker</a>.</p>
7179:
7180: <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
7181: <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
7182: this point.)</p>
7183:
7184: </dd>
7185:
7186: <dt>A start tag whose tag name is one of: "caption", "col",
7187: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
7188: <dd>
7189:
7190: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
7191: <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
7192: a <code>td</code> or <code>th</code> element in table
7193: scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
7194: the token. (<a href="#fragment-case">fragment case</a>)</p>
7195:
7196: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7197: reprocess the current token.</p>
7198:
7199: </dd>
7200:
7201: <dt>An end tag whose tag name is one of: "body", "caption",
7202: "col", "colgroup", "html"</dt>
7203: <dd>
7204: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7205: </dd>
7206:
7207: <dt>An end tag whose tag name is one of: "table", "tbody",
7208: "tfoot", "thead", "tr"</dt>
7209: <dd>
7210:
7211: <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
7212: scope</a> with the same tag name as that of the token
7213: (which can only happen for "tbody", "tfoot" and "thead", or,
7214: in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
7215: error</a> and the token must be ignored.</p>
7216:
7217: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7218: reprocess the current token.</p>
7219:
7220: </dd>
7221:
7222: <dt>Anything else</dt>
7223: <dd>
7224: <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
7225: mode</a>.</p>
7226: </dd>
7227:
7228: </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
7229: mean to run the following algorithm:</p>
7230:
7231: <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>
7232: element in table scope</a>, then act as if an end tag token
7233: with the tag name "td" had been seen.</p></li>
7234:
7235: <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
7236: <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
7237: <code>th</code> element in table scope</a>; act as if an end
7238: tag token with the tag name "th" had been seen.</p></li>
7239:
7240: </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
7241: 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
7242: the same time, nor can it have neither when the <a href="#insertion-mode">insertion
7243: mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
7244: cell</a>".</p>
7245:
7246:
1.755 mike 7247: <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 7248:
7249: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
7250: mode: in select">in select</a>", tokens must be handled as follows:</p>
7251:
7252: <dl class="switch"><dt>A character token</dt>
7253: <dd>
7254: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7255: character</a> into the <a href="#current-node">current node</a>.</p>
7256: </dd>
7257:
7258: <dt>A comment token</dt>
7259: <dd>
7260: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7261: node</a> with the <code title="">data</code> attribute set to
7262: the data given in the comment token.</p>
7263: </dd>
7264:
7265: <dt>A DOCTYPE token</dt>
7266: <dd>
7267: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7268: </dd>
7269:
7270: <dt>A start tag whose tag name is "html"</dt>
7271: <dd>
7272: <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
7273: mode</a>.</p>
7274: </dd>
7275:
7276: <dt>A start tag whose tag name is "option"</dt>
7277: <dd>
7278:
7279: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7280: element, act as if an end tag with the tag name "option" had
7281: been seen.</p>
7282:
7283: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7284:
7285: </dd>
7286:
7287: <dt>A start tag whose tag name is "optgroup"</dt>
7288: <dd>
7289:
7290: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7291: element, act as if an end tag with the tag name "option" had
7292: been seen.</p>
7293:
7294: <p>If the <a href="#current-node">current node</a> is an
7295: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
7296: tag name "optgroup" had been seen.</p>
7297:
7298: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7299:
7300: </dd>
7301:
7302: <dt>An end tag whose tag name is "optgroup"</dt>
7303: <dd>
7304:
7305: <p>First, if the <a href="#current-node">current node</a> is an
7306: <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
7307: it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
7308: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
7309: the tag name "option" had been seen.</p>
7310:
7311: <p>If the <a href="#current-node">current node</a> is an
7312: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
7313: <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
7314: <a href="#parse-error">parse error</a>; ignore the token.</p>
7315:
7316: </dd>
7317:
7318: <dt>An end tag whose tag name is "option"</dt>
7319: <dd>
7320:
7321: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7322: element, then pop that node from the <a href="#stack-of-open-elements">stack of open
7323: elements</a>. Otherwise, this is a <a href="#parse-error">parse
7324: error</a>; ignore the token.</p>
7325:
7326: </dd>
7327:
7328: <dt>An end tag whose tag name is "select"</dt>
7329: <dd>
7330:
7331: <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
7332: scope</a> with the same tag name as the token, this is a
7333: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7334: case</a>)</p>
7335:
7336: <p>Otherwise:</p>
7337:
7338: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
7339: until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
7340: stack.</p>
7341:
7342: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
7343:
7344: </dd>
7345:
7346: <dt>A start tag whose tag name is "select"</dt>
7347: <dd>
7348:
7349: <p><a href="#parse-error">Parse error</a>. Act as if the token had been
7350: an end tag with the tag name "select" instead.</p>
7351:
7352: </dd>
7353:
7354: <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
7355: <dd>
1.73 mike 7356:
7357: <p><a href="#parse-error">Parse error</a>.</p>
7358:
1.124 mike 7359: <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>
7360: element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
7361: case</a>)</p>
1.73 mike 7362:
7363: <p>Otherwise, act as if an end tag with the tag name "select" had
7364: been seen, and reprocess the token.</p>
7365:
1.1 mike 7366: </dd>
7367:
7368: <dt>A start tag token whose tag name is "script"</dt>
7369: <dd>
7370: <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
7371: mode</a>.</p>
7372: </dd>
7373:
7374: <dt>An end-of-file token</dt>
7375: <dd>
7376:
7377: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7378: <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 7379: error</a>.</p>
7380:
7381: <p class="note">It can only be the <a href="#current-node">current node</a> in
7382: the <a href="#fragment-case">fragment case</a>.</p>
7383:
7384: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7385:
7386: </dd>
7387:
7388: <dt>Anything else</dt>
7389: <dd>
7390: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7391: </dd>
7392:
1.755 mike 7393: </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 7394:
7395: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
7396: mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
7397:
7398: <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
7399: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7400: <dd>
7401: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
7402: name "select" had been seen, and reprocess the token.</p>
7403: </dd>
7404:
7405: <dt>An end tag whose tag name is one of: "caption", "table",
7406: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7407: <dd>
7408:
7409: <p><a href="#parse-error">Parse error</a>.</p>
7410:
7411: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
7412: element in table scope</a> with the same tag name as that
7413: of the token, then act as if an end tag with the tag name
7414: "select" had been seen, and reprocess the token. Otherwise,
7415: ignore the token.</p>
7416:
7417: </dd>
7418:
7419: <dt>Anything else</dt>
7420: <dd>
7421: <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
7422: mode</a>.</p>
7423: </dd>
7424:
1.755 mike 7425: </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 7426:
7427: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
7428: mode: in foreign content">in foreign content</a>", tokens must be
7429: handled as follows:</p>
7430:
7431: <dl class="switch"><dt>A character token</dt>
7432: <dd>
7433:
7434: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7435: character</a> into the <a href="#current-node">current node</a>.</p>
7436:
7437: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
7438: LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
7439: (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
7440: flag</a> to "not ok".</p>
7441:
7442: </dd>
7443:
7444: <dt>A comment token</dt>
7445: <dd>
7446: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7447: node</a> with the <code title="">data</code> attribute set to
7448: the data given in the comment token.</p>
7449: </dd>
7450:
7451: <dt>A DOCTYPE token</dt>
7452: <dd>
7453: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7454: </dd>
7455:
1.724 mike 7456: <dt>An end tag whose tag name is "script", if the <a href="#current-node">current node</a> is a <code title="">script</code> element in the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dt>
1.1 mike 7457: <dd>
7458:
7459: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7460: elements</a>.</p>
7461:
7462: <p>Let the <var title="">old insertion point</var> have the
7463: same value as the current <a href="#insertion-point">insertion point</a>. Let
7464: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
7465: input character</a>.</p>
7466:
7467: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
7468: one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
7469:
7470: <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
7471: the <code title="">script</code> element</a> according to the SVG
1.187 mike 7472: rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1 mike 7473:
1.159 mike 7474: <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 7475: tokenizer</a>, the parser will not be executed reentrantly,
7476: since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
7477:
7478: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
7479: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
7480: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
7481:
7482: <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
7483: <a href="#insertion-point">insertion point</a> to its previous value. This value
7484: might be the "undefined" value.)</p>
7485:
7486: </dd>
7487:
1.724 mike 7488: <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">mi</code> element in the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
7489: <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">mo</code> element in the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
7490: <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">mn</code> element in the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
7491: <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>
7492: <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>
7493: <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>
7494: <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>
7495: <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>
7496: <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>
7497: <dt>A start tag, if the <a href="#current-node">current node</a> is an element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</dt>
1.1 mike 7498: <dt>An end tag</dt>
7499: <dd>
7500:
7501: <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
7502: <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7503:
7504: <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
7505: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336 mike 7506: content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
7507: element in scope">in scope</a> that has a namespace other than
1.724 mike 7508: the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1 mike 7509: mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7510:
7511: </dd>
7512:
7513: <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
7514: "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422 mike 7515: "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
7516: uniformly throughout the parser -->, "em", "embed", "h1", "h2",
7517: "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1 mike 7518: completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
7519: "li", "listing"<!-- so that pre and listing can be handled
7520: uniformly throughout the parser -->, "menu", "meta", "nobr",
7521: "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
7522: the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
7523: "span", "strong", "strike"<!-- so that s and strike can be handled
7524: uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305 mike 7525: "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
7526: list was determined empirically by studying over 6,000,000,000
1.422 mike 7527: pages that were specifically not XML pages -->
7528: <dt>A start tag whose tag name is "font", if the token has any
7529: attributes named "color", "face", or "size"</dt> <!-- the
7530: attributes here are required so that SVG <font> will go through as
7531: SVG but legacy <font>s won't -->
7532: <dt>An end-of-file token</dt> <dd>
1.1 mike 7533:
7534: <p><a href="#parse-error">Parse error</a>.</p>
7535:
7536: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
1.724 mike 7537: the <a href="#current-node">current node</a> is in the <a href="infrastructure.html#html-namespace-0">HTML
1.1 mike 7538: namespace</a>.</p>
7539:
7540: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#secondary-insertion-mode">secondary
7541: insertion mode</a>, and reprocess the token.</p>
7542:
7543: </dd>
7544:
7545: <dt>Any other start tag</dt>
7546: <dd>
7547:
7548: <p>If the <a href="#current-node">current node</a> is an element in the
1.724 mike 7549: <a href="infrastructure.html#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
1.1 mike 7550: attributes</a> for the token. (This fixes the case of MathML
7551: attributes that are not all lowercase.)</p>
7552:
1.724 mike 7553: <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 7554: namespace</a>, and the token's tag name is one of the ones in
7555: the first column of the following table, change the tag name to
7556: the name given in the corresponding cell in the second
7557: column. (This fixes the case of SVG elements that are not all
7558: lowercase.)</p>
7559:
7560: <table><thead><tr><th> Tag name </th><th> Element name
7561: </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
7562: </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
7563: </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
7564: </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
7565: </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
7566: </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
7567: </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
7568: </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
7569: </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
7570: </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
7571: </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
7572: </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
7573: </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
7574: </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
7575: </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
7576: </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
7577: </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
7578: </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
7579: </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
7580: </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
7581: </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
7582: </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
7583: </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
7584: </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
7585: </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
7586: </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
7587: </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
7588: </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
7589: </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
7590: </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
7591: </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
7592: </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
7593: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
7594: </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
7595: </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
7596: <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
7597: </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
1.724 mike 7598: </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 7599: namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
7600: token. (This fixes the case of SVG attributes that are not all
7601: lowercase.)</p>
7602:
7603: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
7604: fixes the use of namespaced attributes, in particular XLink in
7605: SVG.)</p>
7606:
7607: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
7608: same namespace as the <a href="#current-node">current node</a>.</p>
7609:
7610: <p>If the token has its <i>self-closing flag</i> set, pop the
7611: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7612: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
7613: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
7614:
7615: </dd>
7616:
1.755 mike 7617: </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 7618:
7619: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
7620: mode: after body">after body</a>", tokens must be handled as follows:</p>
7621:
7622: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7623: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7624: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7625: <dd>
7626: <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
7627: mode</a>.</p>
7628: </dd>
7629:
7630: <dt>A comment token</dt>
7631: <dd>
7632: <p>Append a <code>Comment</code> node to the first element in
1.159 mike 7633: 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 7634: element), with the <code title="">data</code> attribute set to
7635: the data given in the comment token.</p>
7636: </dd>
7637:
7638: <dt>A DOCTYPE token</dt>
7639: <dd>
7640: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7641: </dd>
7642:
7643: <dt>A start tag whose tag name is "html"</dt>
7644: <dd>
7645: <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
7646: mode</a>.</p>
7647: </dd>
7648:
7649: <dt>An end tag whose tag name is "html"</dt>
7650: <dd>
7651:
7652: <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
7653: fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
7654: error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
7655:
7656: <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
7657: body</a>".</p>
7658:
7659: </dd>
7660:
7661: <dt>An end-of-file token</dt>
7662: <dd>
7663: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7664: </dd>
7665:
7666: <dt>Anything else</dt>
7667: <dd>
7668:
7669: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
7670: mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
7671: body</a>" and reprocess the token.</p>
7672:
7673: </dd>
7674:
1.755 mike 7675: </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 7676:
7677: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
7678: mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
7679:
7680: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7681: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7682: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7683: <dd>
7684: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7685: the <a href="#current-node">current node</a>.</p>
7686: </dd>
7687:
7688: <dt>A comment token</dt>
7689: <dd>
7690: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7691: node</a> with the <code title="">data</code> attribute set to
7692: the data given in the comment token.</p>
7693: </dd>
7694:
7695: <dt>A DOCTYPE token</dt>
7696: <dd>
7697: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7698: </dd>
7699:
7700: <dt>A start tag whose tag name is "html"</dt>
7701: <dd>
7702: <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
7703: mode</a>.</p>
7704: </dd>
7705:
7706: <dt>A start tag whose tag name is "frameset"</dt>
7707: <dd>
7708: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7709: </dd>
7710:
7711: <dt>An end tag whose tag name is "frameset"</dt>
7712: <dd>
7713:
7714: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 7715: <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 7716: error</a>; ignore the token. (<a href="#fragment-case">fragment
7717: case</a>)</p>
7718:
7719: <p>Otherwise, pop the <a href="#current-node">current node</a> from the
7720: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7721:
7722: <p>If the parser was <em>not</em> originally created as part
7723: of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
7724: (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5 mike 7725: node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1 mike 7726: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
7727: frameset</a>".</p>
7728:
7729: </dd>
7730:
7731: <dt>A start tag whose tag name is "frame"</dt>
7732: <dd>
7733:
7734: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
7735: Immediately pop the <a href="#current-node">current node</a> off the
7736: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7737:
7738: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
7739: token's <i>self-closing flag</i></a>, if it is set.</p>
7740:
7741: </dd>
7742:
7743: <dt>A start tag whose tag name is "noframes"</dt>
7744: <dd>
7745: <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
7746: mode</a>.</p>
7747: </dd>
7748:
7749: <dt>An end-of-file token</dt>
7750: <dd>
7751:
7752: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7753: <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 7754: error</a>.</p>
7755:
7756: <p class="note">It can only be the <a href="#current-node">current node</a> in
7757: the <a href="#fragment-case">fragment case</a>.</p>
7758:
7759: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7760:
7761: </dd>
7762:
7763: <dt>Anything else</dt>
7764: <dd>
7765: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7766: </dd>
7767:
1.755 mike 7768: </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 7769:
7770: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
7771: mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
7772:
7773: <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
7774: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7775: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7776: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7777: <dd>
7778: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7779: the <a href="#current-node">current node</a>.</p>
7780: </dd>
7781:
7782: <dt>A comment token</dt>
7783: <dd>
7784: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7785: node</a> with the <code title="">data</code> attribute set to
7786: the data given in the comment token.</p>
7787: </dd>
7788:
7789: <dt>A DOCTYPE token</dt>
7790: <dd>
7791: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7792: </dd>
7793:
7794: <dt>A start tag whose tag name is "html"</dt>
7795: <dd>
7796: <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
7797: mode</a>.</p>
7798: </dd>
7799:
7800: <dt>An end tag whose tag name is "html"</dt>
7801: <dd>
7802: <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
7803: frameset</a>".</p>
7804: </dd>
7805:
7806: <dt>A start tag whose tag name is "noframes"</dt>
7807: <dd>
7808: <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
7809: mode</a>.</p>
7810: </dd>
7811:
7812: <dt>An end-of-file token</dt>
7813: <dd>
7814: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7815: </dd>
7816:
7817: <dt>Anything else</dt>
7818: <dd>
7819: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7820: </dd>
7821:
1.755 mike 7822: </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 7823:
7824: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
7825: mode: after after body">after after body</a>", tokens must be handled as follows:</p>
7826:
7827: <dl class="switch"><dt>A comment token</dt>
7828: <dd>
1.810 mike 7829: <p>Append a <code>Comment</code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 7830: object with the <code title="">data</code> attribute set to the
7831: data given in the comment token.</p>
7832: </dd>
7833:
7834: <dt>A DOCTYPE token</dt>
7835: <dt>A character token that is one of U+0009 CHARACTER
7836: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7837: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7838: <dt>A start tag whose tag name is "html"</dt>
7839: <dd>
7840: <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
7841: mode</a>.</p>
7842: </dd>
7843:
7844: <dt>An end-of-file token</dt>
7845: <dd>
7846: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7847: </dd>
7848:
7849: <dt>Anything else</dt>
7850: <dd>
7851: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7852: to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
7853: reprocess the token.</p>
7854: </dd>
7855:
1.755 mike 7856: </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 7857:
7858: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
7859: mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
7860:
7861: <dl class="switch"><dt>A comment token</dt>
7862: <dd>
1.810 mike 7863: <p>Append a <code>Comment</code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 7864: object with the <code title="">data</code> attribute set to the
7865: data given in the comment token.</p>
7866: </dd>
7867:
7868: <dt>A DOCTYPE token</dt>
7869: <dt>A character token that is one of U+0009 CHARACTER
7870: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7871: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7872: <dt>A start tag whose tag name is "html"</dt>
7873: <dd>
7874: <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
7875: mode</a>.</p>
7876: </dd>
7877:
7878: <dt>An end-of-file token</dt>
7879: <dd>
7880: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7881: </dd>
7882:
7883: <dt>A start tag whose tag name is "noframes"</dt>
7884: <dd>
7885: <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
7886: mode</a>.</p>
7887: </dd>
7888:
7889: <dt>Anything else</dt>
7890: <dd>
7891: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7892: </dd>
7893:
1.266 mike 7894: </dl></div><div class="impl">
7895:
1.755 mike 7896: <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 7897:
7898: <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484 mike 7899: the document, the user agent must run the following steps:</p>
1.1 mike 7900:
1.484 mike 7901: <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
7902: "interactive" <!-- this also synchronously fires an event --> and
7903: the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
7904:
1.838 mike 7905: <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
7906: elements</a>.</p></li>
7907:
1.484 mike 7908: <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
7909: document has finished parsing</a> is not empty, run these
7910: substeps:</p>
7911:
1.794 mike 7912: <ol><li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the first
1.484 mike 7913: <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
7914: execute when the document has finished parsing</a> has its
7915: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
7916: is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
7917: blocking scripts</a>.</p></li>
7918:
7919: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
7920: 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
7921: execute when the document has finished parsing</a>.</p></li>
7922:
7923: <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
7924: <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
7925: finished parsing</a> (i.e. shift out the first entry in the
7926: list).</p></li>
7927:
7928: <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
7929: document has finished parsing</a> is still not empty, repeat
7930: these substeps again from substep 1.</p>
7931:
7932: </li></ol></li>
7933:
1.794 mike 7934: <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the <a href="semantics.html#list-of-scripts-that-will-execute-as-soon-as-possible">list of
1.484 mike 7935: scripts that will execute as soon as possible</a> is
7936: empty.</p></li>
7937:
1.794 mike 7938: <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 7939: event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
1.810 mike 7940: <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484 mike 7941:
1.794 mike 7942: <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
1.484 mike 7943: <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
1.810 mike 7944: the <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484 mike 7945:
1.794 mike 7946: <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 7947: readiness</a> to "complete". <!-- this also fires an event
7948: synchronously during the task --></p></li>
1.1 mike 7949:
1.810 mike 7950: <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 7951: 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 7952: simple event</a> named <code title="event-load">load</code> at
1.810 mike 7953: the <code><a href="infrastructure.html#document">Document</a></code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
1.1 mike 7954: its <code title="dom-event-target">target</code> set to the
1.810 mike 7955: <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 7956: <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1 mike 7957:
1.810 mike 7958: <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 7959: 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
7960: <code><a href="browsers.html#window">Window</a></code> object of the <code><a href="infrastructure.html#document">Document</a></code>, but with
7961: its <code title="dom-event-target">target</code> set to the
7962: <code><a href="infrastructure.html#document">Document</a></code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
7963: <code><a href="browsers.html#window">Window</a></code> object), using the
7964: <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>
7965: attribute set to false. This event must not bubble, must not be
7966: cancelable, and has no default action.</p></li>
1.569 mike 7967:
1.810 mike 7968: <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 7969: 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 7970: <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 7971: <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
7972: current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484 mike 7973: must bubble but not be cancelable and has no default
7974: action.</p></li>
1.1 mike 7975:
1.810 mike 7976: <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 7977: 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 7978: the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application cache download process
7979: tasks</a>, and then empty the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application
1.794 mike 7980: cache download process tasks</a>. The <a href="webappapis.html#task-source">task source</a>
7981: for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the
7982: <a href="webappapis.html#networking-task-source">networking task source</a>.</p></li>
1.725 mike 7983:
1.810 mike 7984: <li><p>The <code><a href="infrastructure.html#document">Document</a></code> is now <dfn id="completely-loaded">completely
1.725 mike 7985: loaded</dfn>.</p></li>
7986:
1.838 mike 7987: </ol><p>When the user agent is to <dfn id="abort-an-html-parser">abort an HTML parser</dfn>, it
7988: must run the following steps:</p>
7989:
7990: <ol><li><p>Throw away any pending content in the <a href="#the-input-stream">input
7991: stream</a>, and discard any future content that would have been
7992: added to it.</p></li>
7993:
7994: <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
7995: elements</a>.</p></li>
7996:
7997: <!-- anything else? this is things that happen when you call
7998: document.open() on a document that's still being parsed. Should the
7999: pending scripts be blown away or anything? -->
8000:
1.794 mike 8001: </ol><p>Except where otherwise specified, the <a href="webappapis.html#task-source">task source</a>
8002: for the <a href="webappapis.html#concept-task" title="concept-task">tasks</a> mentioned in this
8003: section is the <a href="webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1 mike 8004:
1.266 mike 8005: </div><div class="impl">
1.1 mike 8006:
1.755 mike 8007: <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 8008:
8009: <p>When an application uses an <a href="#html-parser">HTML parser</a> in
8010: conjunction with an XML pipeline, it is possible that the
8011: constructed DOM is not compatible with the XML tool chain in certain
8012: subtle ways. For example, an XML toolchain might not be able to
8013: represent attributes with the name <code title="">xmlns</code>,
8014: since they conflict with the Namespaces in XML syntax. There is also
8015: some data that the <a href="#html-parser">HTML parser</a> generates that isn't
8016: included in the DOM itself. This section specifies some rules for
8017: handling these issues.</p>
8018:
8019: <p>If the XML API being used doesn't support DOCTYPEs, the tool may
8020: drop DOCTYPEs altogether.</p>
8021:
8022: <p>If the XML API doesn't support attributes in no namespace that
8023: are named "<code title="">xmlns</code>", attributes whose names
8024: start with "<code title="">xmlns:</code>", or attributes in the
1.724 mike 8025: <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
1.1 mike 8026: attributes.</p>
8027:
8028: <p>The tool may annotate the output with any namespace declarations
8029: required for proper operation.</p>
8030:
8031: <p>If the XML API being used restricts the allowable characters in
8032: the local names of elements and attributes, then the tool may map
8033: all element and attribute local names that the API wouldn't support
8034: to a set of names that <em>are</em> allowed, by replacing any
8035: character that isn't supported with the uppercase letter U and the
8036: six digits of the character's Unicode code point when expressed in
8037: hexadecimal, using digits 0-9 and capital letters A-F as the
8038: symbols, in increasing numeric order.</p>
8039:
8040: <p class="example">For example, the element name <code title="">foo<bar</code>, which can be output by the <a href="#html-parser">HTML
8041: parser</a>, though it is neither a legal HTML element name nor a
8042: well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
8043: element name (though it's still not legal in HTML by any means).</p>
8044:
8045: <p class="example">As another example, consider the attribute
8046: <code>xlink:href</code>. Used on a MathML element, it becomes, after
8047: being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
8048: attribute with a prefix "<code title="">xlink</code>" and a local
8049: name "<code title="">href</code>". However, used on an HTML element,
8050: it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
8051: might not be accepted by an XML API. It could thus get converted,
8052: becoming "<code title="">xlinkU00003Ahref</code>".</p>
8053:
8054: <p class="note">The resulting names from this conversion
8055: conveniently can't clash with any attribute generated by the
8056: <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
8057: those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
8058: algorithm's table.</p>
8059:
8060: <p>If the XML API restricts comments from having two consecutive
8061: U+002D HYPHEN-MINUS characters (--), the tool may insert a single
8062: U+0020 SPACE character between any such offending characters.</p>
8063:
8064: <p>If the XML API restricts comments from ending in a
8065: U+002D HYPHEN-MINUS character (-), the tool may insert a single
8066: U+0020 SPACE character at the end of such comments.</p>
8067:
8068: <p>If the XML API restricts allowed characters in character data,
1.439 mike 8069: attribute values, or comments, the tool may replace any U+000C FORM
8070: FEED (FF) character with a U+0020 SPACE character, and any other
8071: literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1 mike 8072:
8073: <p>If the tool has no way to convey out-of-band information, then
8074: the tool may drop the following information:</p>
8075:
8076: <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no quirks mode</a></i>,
8077: <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>
8078:
8079: <li>The association between form controls and forms that aren't
8080: their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
8081: <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
8082:
8083: </ul><p class="note">The mutations allowed by this section apply
8084: <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
8085: applied. For example, a <code title=""><a::></code> start tag
8086: will be closed by a <code title=""></a::></code> end tag, and
8087: never by a <code title=""></aU00003AU00003A></code> end tag, even
8088: if the user agent is using the rules above to then generate an
8089: actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
8090:
1.266 mike 8091: </div><div class="impl">
1.1 mike 8092:
1.755 mike 8093: <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 8094:
8095: <p><i>This section is non-normative.</i></p>
8096:
8097: <p>This section examines some erroneous markup and discusses how
8098: the <a href="#html-parser">HTML parser</a> handles these cases.</p>
8099:
8100:
1.755 mike 8101: <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 8102:
8103: <p><i>This section is non-normative.</i></p>
8104:
8105: <p>The most-often discussed example of erroneous markup is as
8106: follows:</p>
8107:
8108: <pre><p>1<b>2<i>3</b>4</i>5</p></pre>
8109:
8110: <p>The parsing of this markup is straightforward up to the "3". At
8111: this point, the DOM looks like this:</p>
8112:
1.159 mike 8113: <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
8114: 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 8115: <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
8116: formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
8117: <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>
8118:
8119: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
8120: invoked. This is a simple case, in that the <var title="">formatting
8121: element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
8122: <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8123: elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8124: <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 8125: active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
8126: DOM tree is unmodified at this point.</p>
8127:
8128: <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
8129: the active formatting elements</a>, in this case just the
8130: <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
8131: for the "4" text node. After the end tag token for the "i" is also
8132: received, and the "5" text node is inserted, the DOM looks as
8133: follows:</p>
8134:
1.755 mike 8135: <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 8136:
8137: <p><i>This section is non-normative.</i></p>
8138:
8139: <p>A case similar to the previous one is the following:</p>
8140:
8141: <pre><b>1<p>2</b>3</p></pre>
8142:
8143: <p>Up to the "2" the parsing here is straightforward:</p>
8144:
1.159 mike 8145: <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 8146: "b" is parsed.</p>
8147:
8148: <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8149: elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8150: <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 8151: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
8152: <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>
8153:
8154: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
8155: in the previous example. However, in this case, there <em>is</em> a
8156: <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
8157: this time the adoption agency algorithm isn't skipped over.</p>
8158:
1.159 mike 8159: <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 8160: element. A conceptual "bookmark" marks the position of the
8161: <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
8162: elements</a>, but since that list has only one element in it,
8163: it won't have much effect.</p>
8164:
8165: <p>As the algorithm progresses, <var title="">node</var> ends up set
8166: to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
8167: node</var> ends up set to the <var title="">furthest block</var>
8168: (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
8169:
8170: <p>The <var title="">last node</var> gets appended (moved) to the
8171: <var title="">common ancestor</var>, so that the DOM looks like:</p>
8172:
1.159 mike 8173: <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 8174: <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
8175:
1.159 mike 8176: <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 8177: <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
8178:
1.159 mike 8179: <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 8180: active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
8181: elements</a>, so that when the "3" is parsed, it is appended to
8182: the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
8183:
1.755 mike 8184: <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><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 8185:
8186: <p><i>This section is non-normative.</i></p>
8187:
8188: <p>Error handling in tables is, for historical reasons, especially
8189: strange. For example, consider the following markup:</p>
8190:
8191: <pre><table><strong><b></strong><tr><td>aaa</td></tr><strong>bbb</strong></table>ccc</pre>
8192:
8193: <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
8194: directly inside a table like that, and the parser handles this case
8195: 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
8196: examining the DOM tree as it stands just after the
8197: <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
8198:
1.159 mike 8199: <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 8200: tag has been seen:</p>
8201:
1.159 mike 8202: <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
8203: 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 8204: <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
8205: resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
8206: elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
8207: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
8208: table">in table</a>".</p>
8209:
8210: <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
8211: to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
8212: 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
8213: then handled in a rather straight-forward manner, taking the parser
8214: through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
8215: body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
8216: row</a>" insertion modes, after which the DOM looks as
8217: follows:</p>
8218:
1.159 mike 8219: <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
8220: 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 8221: <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
8222: formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
8223: it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
8224: mode: in row">in row</a>".</p>
8225:
8226: <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
8227: <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
8228: 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
8229: mode</a>).</p>
8230:
1.159 mike 8231: <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 8232: no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
8233: node:</p>
8234:
1.159 mike 8235: <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 8236: handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159 mike 8237: 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 8238: 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
8239: elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
8240: marker having been removed by the "td" end tag token); and the
8241: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
8242: table body">in table body</a>".</p>
8243:
8244: <p>Thus it is that the "bbb" character tokens are found. These
8245: trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
8246: text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
8247: insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
8248: body">in table body</a>"). The character tokens are collected,
8249: and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
8250: seen, they are processed as a group. Since they are not all spaces,
8251: 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,
8252: which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
8253: body</a>" insertion mode but with <a href="#foster-parent" title="foster
8254: parent">foster parenting</a>.</p>
8255:
8256: <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
8257: active formatting elements are reconstructed</a>, a
8258: <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
8259: parent">foster parented</a>, and then the "bbb" text node is
8260: appended to it:</p>
8261:
1.159 mike 8262: <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
8263: <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 8264: <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
8265: this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
8266: formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
8267: and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
8268: mode: in table body">in table body</a>".</p>
8269:
8270: <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
8271: character">space characters</a> instead of "bbb", then those
8272: <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
8273: appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
8274:
8275: <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
8276: tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
8277: elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
8278: but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
8279: elements</a>, so the "ccc" character tokens after the table
8280: result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
8281: time after the table:</p>
8282:
1.755 mike 8283: <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 8284:
8285: <p><i>This section is non-normative.</i></p>
8286:
8287: <p>Consider the following markup, which for this example we will
8288: 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 8289: content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1 mike 8290: <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
8291:
8292: <pre><div id=a>
8293: <script>
8294: var div = document.getElementById('a');
8295: parent.document.body.appendChild(div);
8296: </script>
8297: <script>
8298: alert(document.URL);
8299: </script>
8300: </div>
8301: <script>
8302: alert(document.URL);
8303: </script></pre>
8304:
8305: <p>Up to the first "script" end tag, before the script is parsed,
8306: the result is relatively straightforward:</p>
8307:
1.306 mike 8308: <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="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="">
8309: </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 8310: and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
8311:
1.810 mike 8312: <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 8313: aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
8314: <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306 mike 8315: <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1 mike 8316:
8317: <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
1.810 mike 8318: is inserted <em>into the outer <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 8319: object</em>.</p>
8320:
1.794 mike 8321: <p>This also means that the <a href="webappapis.html#script-s-global-object">script's global object</a> is
1.1 mike 8322: the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
8323: object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159 mike 8324: <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1 mike 8325:
8326: <p class="note">This isn't a security problem since the script that
1.810 mike 8327: 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
8328: only do so because the two <code><a href="infrastructure.html#document">Document</a></code> object have the
1.714 mike 8329: same <a href="browsers.html#origin">origin</a>.</p>
1.1 mike 8330:
8331: <p>Thus, the first alert says "http://example.com/outer".</p>
8332:
1.306 mike 8333: <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
8334: <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.810 mike 8335: <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 8336:
1.159 mike 8337: <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="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 8338:
8339:
8340:
8341:
1.755 mike 8342: <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 8343:
8344: <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
8345: algorithm</dfn>. The algorithm takes as input a DOM
1.810 mike 8346: <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 8347: exception.</p>
8348:
8349: <p class="note">This algorithm serializes the <em>children</em> of
8350: the node being serialized, not the node itself.</p>
8351:
8352: <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
8353: the empty string.</p></li>
8354:
8355: <li>
8356:
8357: <p>For each child node of <var title="">the node</var>, in
8358: <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
8359:
8360: </p><ol><li><p>Let <var title="">current node</var> be the child node
8361: being processed.</p></li>
8362:
8363: <li>
8364:
8365: <p>Append the appropriate string from the following list to
8366: <var title="">s</var>:</p>
8367:
8368: <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
8369:
8370: <dd>
8371:
1.588 mike 8372: <p>Append a U+003C LESS-THAN SIGN character character (<),
8373: followed by the element's tag name. (For nodes created by the
8374: <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1 mike 8375: lowercase.)</p>
8376:
8377: <p>For each attribute that the element has, append a U+0020
8378: SPACE character, the attribute's name (which, for attributes
8379: 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 8380: U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
8381: character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
8382: <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
8383: character (").</p>
1.1 mike 8384:
8385: <p>While the exact order of attributes is UA-defined, and may
8386: depend on factors such as the order that the attributes were
8387: given in the original markup, the sort order must be stable,
8388: such that consecutive invocations of this algorithm serialize an
8389: element's attributes in the same order.</p>
8390:
1.588 mike 8391: <p>Append a U+003E GREATER-THAN SIGN character (>).</p>
1.1 mike 8392:
8393: <p>If <var title="">current node</var> is an
1.5 mike 8394: <code><a href="the-canvas-element.html#the-area-element">area</a></code>, <code><a href="semantics.html#the-base-element">base</a></code>, <code><a href="obsolete.html#basefont">basefont</a></code>,
1.724 mike 8395: <code><a href="obsolete.html#bgsound">bgsound</a></code>, <code><a href="semantics.html#the-br-element">br</a></code>, <code><a href="tabular-data.html#the-col-element">col</a></code>,
1.159 mike 8396: <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>,
8397: <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 8398: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="semantics.html#meta">meta</a></code>, <code><a href="text-level-semantics.html#the-param-element">param</a></code>, or
1.724 mike 8399: <code><a href="obsolete.html#wbr">wbr</a></code> element, then continue on to the next child
1.589 mike 8400: node at this point.</p> <!-- also, i guess: image and isindex,
8401: but we don't list those because we don't consider those
8402: "elements", more "macros", and thus we should never serialize
8403: them -->
1.1 mike 8404:
8405: <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42 mike 8406: <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 8407: a U+000A LINE FEED (LF) character.</p>
8408:
8409: <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
8410: serialization algorithm</a> on the <var title="">current
8411: node</var> element (thus recursing into this algorithm for
1.588 mike 8412: that element), followed by a U+003C LESS-THAN SIGN character
8413: (<), a U+002F SOLIDUS character (/), the element's tag name
8414: again, and finally a U+003E GREATER-THAN SIGN character
8415: (>).</p>
1.1 mike 8416:
8417: </dd>
8418:
8419:
8420: <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
8421: node</dt>
8422:
8423: <dd>
8424:
1.19 mike 8425: <p>If the parent of <var title="">current node</var> is a
1.42 mike 8426: <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 8427: <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 8428: <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
8429: if the parent of <var title="">current node</var> is
1.794 mike 8430: <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 8431: node, then append the value of <var title="">current
8432: node</var>'s <code title="">data</code> IDL attribute
8433: literally.</p>
1.1 mike 8434:
8435: <p>Otherwise, append the value of <var title="">current
1.192 mike 8436: node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1 mike 8437: below</a>.</p>
8438:
8439: </dd>
8440:
8441:
8442: <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
8443:
8444: <dd>
8445:
8446: <p>Append the literal string <code><!--</code> (U+003C
8447: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192 mike 8448: U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8449: attribute, followed by the literal string <code>--></code>
8450: (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
8451: SIGN).</p>
8452:
8453: </dd>
8454:
8455:
8456: <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
8457:
8458: <dd>
8459:
8460: <p>Append the literal string <code><?</code> (U+003C
8461: LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192 mike 8462: of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
8463: U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8464: attribute, followed by a single U+003E GREATER-THAN SIGN
1.464 mike 8465: character (>).</p>
1.1 mike 8466:
8467: </dd>
8468:
8469:
8470: <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
8471:
8472: <dd>
8473:
8474: <p>Append the literal string <code><!DOCTYPE</code> (U+003C
8475: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
8476: LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
8477: LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
8478: LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
8479: LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192 mike 8480: value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1 mike 8481: string <code>></code> (U+003E GREATER-THAN SIGN).</p>
8482:
8483: </dd>
8484:
8485:
8486: </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
8487: occur as children of elements. If, despite this, they somehow do
8488: occur, this algorithm must raise an
8489: <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
8490:
8491: </li>
8492:
8493: </ol></li>
8494:
8495: <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
8496:
8497: </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
8498: purposes of the algorithm above) consists of replacing any
8499: occurrences of the "<code title="">&</code>" character by the
8500: string "<code title="">&amp;</code>", any occurrences of the
8501: U+00A0 NO-BREAK SPACE character by the string "<code title="">&nbsp;</code>", and, if the algorithm was invoked in
8502: 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
8503: 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>
8504:
8505: <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
8506: agent, and are therefore not covered in the algorithm above.</p>
8507:
8508: <p class="note">It is possible that the output of this algorithm, if
8509: parsed with an <a href="#html-parser">HTML parser</a>, will not return the
8510: original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
8511: element to which a <code title="">Comment</code> node has been
8512: appended is serialized and the output is then reparsed, the comment
8513: will end up being displayed in the text field. Similarly, if, as a
8514: result of DOM manipulation, an element contains a comment that
8515: contains the literal string "<code title="">--></code>", then
8516: when the result of serializing the element is parsed, the comment
8517: will be truncated at that point and the rest of the comment will be
8518: interpreted as markup. More examples would be making a
8519: <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
8520: "<code></script></code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
8521: 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
8522: <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
8523: tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
8524:
8525:
1.755 mike 8526: <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 8527:
8528: <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
8529: algorithm</dfn>. The algorithm optionally takes as input an
1.810 mike 8530: <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 8531: parser, as well as <var title="">input</var>, a string to parse, and
8532: returns a list of zero or more nodes.</p>
8533:
8534: <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
8535: in the parser section are parts that only occur if the parser was
8536: created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
8537: with such markings for informational purposes only; such markings
8538: have no normative weight. If it is possible for a condition
8539: described as a <a href="#fragment-case">fragment case</a> to occur even when the
8540: parser wasn't created for the purposes of handling this algorithm,
8541: then that is an error in the specification.</p>
8542:
8543: <ol><li>
8544:
1.810 mike 8545: <p>Create a new <code><a href="infrastructure.html#document">Document</a></code> node, and mark it as being
1.1 mike 8546: an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
8547:
8548: </li>
8549:
8550: <li>
8551:
8552: <p>If there is a <var title="">context</var> element, and the
1.810 mike 8553: <code><a href="infrastructure.html#document">Document</a></code> of the <var title="">context</var> element
8554: is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code>
8555: 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.1 mike 8556: the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited quirks
1.810 mike 8557: mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code> be in
1.1 mike 8558: <a href="dom.html#limited-quirks-mode">limited quirks mode</a>. Otherwise, leave the
1.810 mike 8559: <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 8560:
8561: </li>
8562:
8563: <li>
8564:
8565: <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
1.810 mike 8566: the just created <code><a href="infrastructure.html#document">Document</a></code> node.</p>
1.1 mike 8567:
8568: </li>
8569:
8570: <li>
8571:
8572: <p>If there is a <var title="">context</var> element, run these
8573: substeps:</p>
8574:
8575: <ol><li>
8576:
1.541 mike 8577: <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
8578: <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1 mike 8579:
1.159 mike 8580: <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 8581: element</dt>
8582:
1.541 mike 8583: <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 8584:
8585:
1.672 mike 8586: <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>,
8587: <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 8588: <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1 mike 8589:
1.541 mike 8590: <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 8591:
8592:
1.672 mike 8593: <dt>If it is a <code><a href="semantics.html#script">script</a></code> element</dt>
8594:
8595: <dd>Switch the tokenizer to the <a href="#script-data-state">script data state</a>.</dd>
8596:
8597:
1.1 mike 8598: <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
8599:
1.541 mike 8600: <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
8601: tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>. Otherwise,
8602: leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8603:
8604:
1.42 mike 8605: <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1 mike 8606:
1.541 mike 8607: <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
8608: state</a>.</dd>
1.1 mike 8609:
8610:
8611: <dt>Otherwise</dt>
8612:
1.541 mike 8613: <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8614:
1.672 mike 8615: </dl><p class="note">For performance reasons, an implementation that
1.756 mike 8616: does not report errors and that uses the actual state machine
8617: described in this specification directly could use the PLAINTEXT
8618: state instead of the RAWTEXT and script data states where those
8619: are mentioned in the list above. Except for rules regarding
8620: parse errors, they are equivalent, since there is no
8621: <a href="#appropriate-end-tag-token">appropriate end tag token</a> in the fragment case, yet
8622: they involve far fewer state transitions.</p>
1.672 mike 8623:
8624: </li>
1.1 mike 8625:
8626: <li>
8627:
1.159 mike 8628: <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 8629: with no attributes.</p>
8630:
8631: </li>
8632:
8633: <li>
8634:
8635: <p>Append the element <var title="">root</var> to the
1.810 mike 8636: <code><a href="infrastructure.html#document">Document</a></code> node created above.</p>
1.1 mike 8637:
8638: </li>
8639:
8640: <li>
8641:
8642: <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
8643: it contains just the single element <var title="">root</var>.</p>
8644:
8645: </li>
8646:
8647: <li>
8648:
8649: <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
8650: parser's insertion mode appropriately</a>.</p>
8651:
8652: <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
8653:
8654: </li>
8655:
8656: <li>
8657:
8658: <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
8659: to the nearest node to the <var title="">context</var> element
8660: that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
8661: ancestor chain, and including the element itself, if it is a
8662: <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
8663: <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
8664:
8665: </li>
8666:
8667: </ol></li>
8668:
8669: <li>
8670:
8671: <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
8672: parser</a> just created the <var title="">input</var>. The
8673: encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
8674: <i>irrelevant</i>.</p>
8675:
8676: </li>
8677:
8678: <li>
8679:
8680: <p>Start the parser and let it run until it has consumed all the
8681: characters just inserted into the input stream.</p>
8682:
8683: </li>
8684:
8685: <li>
8686:
8687: <p>If there is a <var title="">context</var> element, return the
8688: child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
8689: order</a>.</p>
8690:
1.810 mike 8691: <p>Otherwise, return the children of the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 8692: object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
8693:
8694: </li>
8695:
1.123 mike 8696: </ol></div></body></html>
Webmaster