Annotation of html5/spec/syntax.html, revision 1.638
1.2 mike 1: <!DOCTYPE HTML>
1.258 mike 2: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><head><title>9 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; }
47: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #EEFFEE; }
48: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
49: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
50: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
51: dl.domintro dd p { margin: 0.5em 0; }
52: dl.switch { padding-left: 2em; }
53: dl.switch > dt { text-indent: -1.5em; }
54: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
55: dl.triple { padding: 0 0 0 1em; }
56: dl.triple dt, dl.triple dd { margin: 0; display: inline }
57: dl.triple dt:after { content: ':'; }
58: dl.triple dd:after { content: '\A'; white-space: pre; }
59: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
60: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
61: a .diff-new { border-bottom: 1px blue solid; }
62:
63: h2 { page-break-before: always; }
64: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
65: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
66:
67: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
68:
69: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
70: div.head p { margin: 0; }
71: div.head h1 { margin: 0; }
72: div.head .logo { float: right; margin: 0 1em; }
73: div.head .logo img { border: none } /* remove border from top image */
74: div.head dl { margin: 1em 0; }
75: p.copyright { font-size: x-small; font-style: oblique; margin: 0; }
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.267 mike 169: </style><style type="text/css">
170:
1.292 mike 171: .applies thead th > * { display: block; }
172: .applies thead code { display: block; }
173: .applies tbody th { whitespace: nowrap; }
174: .applies td { text-align: center; }
175: .applies .yes { background: yellow; }
176:
1.267 mike 177: .matrix, .matrix td { border: none; text-align: right; }
178: .matrix { margin-left: 2em; }
179:
180: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
181: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
182: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
183:
184: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
185: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
186: #table-example-1 caption { padding-bottom: 0.5em; }
187: #table-example-1 thead, #table-example-1 tbody { border: none; }
188: #table-example-1 th, #table-example-1 td { border: solid thin; }
189: #table-example-1 th { font-weight: normal; }
190: #table-example-1 td { border-style: none solid; vertical-align: top; }
191: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
192: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
193: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
194: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
195: #table-example-1 tbody td:first-child::after { content: leader(". "); }
196: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
197: #table-example-1 tbody td:first-child + td { width: 10em; }
198: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
199: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
200:
201: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
202: .apple-table-examples * { font-family: "Times", serif; }
203: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
204: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
205: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
206: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
207: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
208: .apple-table-examples td { text-align: right; vertical-align: top; }
209: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
210: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
211: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
212: .apple-table-examples sup { line-height: 0; }
213:
1.235 mike 214: </style><link href="data:text/css," rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D" rel="alternate stylesheet" title="Highlight implementation requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css"><!-- ZZZ ED vs WD -->
1.2 mike 215: <script src="link-fixup.js"></script>
216: <link href="comms.html" title="8 Communication" rel="prev">
217: <link href="spec.html#contents" title="Table of contents" rel="index">
1.1 mike 218: <link href="named-character-references.html" title="9.6 Named character references" rel="next">
1.16 mike 219: </head><body onload="fixBrokenLink(); fixBrokenLink()"><div class="head">
1.1 mike 220: <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 221: <h1>HTML5</h1>
1.1 mike 222: <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 223: </div><nav>
1.1 mike 224: <a href="comms.html">← 8 Communication</a> –
1.2 mike 225: <a href="spec.html#contents">Table of contents</a> –
1.1 mike 226: <a href="named-character-references.html">9.6 Named character references →</a>
1.638 ! mike 227: </nav><p>This is revision 1.3474.</p>
1.11 mike 228:
1.1 mike 229:
1.123 mike 230: <h2 id="syntax"><span class="secno">9 </span><dfn>The HTML syntax</dfn></h2><p class="note">This section only describes the rules for
1.605 mike 231: <code><a href="iana.html#text-html">text/html</a></code> resources. Rules for XML resources are
1.1 mike 232: discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.614 mike 233: syntax</a>".</p><h3 id="writing"><span class="secno">9.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 234:
235: <p><i>This section only applies to documents, authoring tools, and
236: markup generators. In particular, it does not apply to conformance
237: checkers; conformance checkers must use the requirements given in
238: the next section ("parsing HTML documents").</i></p>
239:
1.123 mike 240: </div><p>Documents must consist of the following parts, in the given
241: order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1 mike 242:
243: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
244: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
245:
246: <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
247:
248: </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
249: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
250:
1.159 mike 251: <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 252:
253: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
254: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
255:
256: </ol><p>The various types of content mentioned above are described in the
1.123 mike 257: 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 258: declarations</a> are to be serialized, as discussed in the
1.123 mike 259: section on that topic.</p><div class="note">
1.1 mike 260:
1.159 mike 261: <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
262: space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
263: before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1 mike 264: document is parsed; space characters <em>after</em> the root
1.159 mike 265: <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
266: of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1 mike 267: root element do not round-trip.</p>
268:
269: <p>It is suggested that newlines be inserted after the DOCTYPE,
270: after any comments that are before the root element, after the
1.159 mike 271: <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
272: that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
273: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 274:
1.123 mike 275: </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1 mike 276: their attributes) are case-insensitive, but only for characters in
1.547 mike 277: the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
278: LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1 mike 279: LETTER Z). For convenience, in this section this is just referred to
1.614 mike 280: as "case-insensitive".</p><h4 id="the-doctype"><span class="secno">9.1.1 </span>The DOCTYPE</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments. </i><span><a href="http://www.w3.org/html/wg/tracker/issues/4">ISSUE-4</a> (html-versioning) blocks progress to Last Call</span></p><p>A <dfn id="syntax-doctype" title="syntax-doctype">DOCTYPE</dfn> is a mostly useless,
1.123 mike 281: but required, header.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1 mike 282: omitted, browsers tend to use a different rendering mode that is
283: incompatible with some specifications. Including the DOCTYPE in a
284: document ensures that the browser makes a best-effort attempt at
1.123 mike 285: following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.588 mike 286: order:</p><ol class="brief"><li>A U+003C LESS-THAN SIGN character (<).</li>
287: <li>A U+0021 EXCLAMATION MARK character (!).</li>
1.1 mike 288: <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>
289: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
290: <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>
291: <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> (defined below).</li>
292: <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.588 mike 293: <li>A U+003E GREATER-THAN SIGN character (>).</li>
1.1 mike 294: </ol><p class="note">In other words, <code><!DOCTYPE HTML></code>,
1.123 mike 295: case-insensitively.</p><p>For the purposes of HTML generators that cannot output HTML
1.1 mike 296: markup with the short DOCTYPE "<code title=""><!DOCTYPE
297: HTML></code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
298: into the DOCTYPE (in the position defined above). This string must
1.123 mike 299: 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 300: <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 301: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 302: <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465 mike 303: <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.1 mike 304: <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>
305: </ol><p class="note">In other words, <code><!DOCTYPE HTML SYSTEM
306: "about:legacy-compat"></code> or <code><!DOCTYPE HTML SYSTEM
307: 'about:legacy-compat'></code>, case-insensitively except for the bit
1.123 mike 308: in quotes.</p><p>The <a href="#doctype-legacy-string">DOCTYPE legacy string</a> should not be used unless
1.1 mike 309: the document is generated from a system that cannot output the
1.614 mike 310: shorter string.</p><h4 id="elements-0"><span class="secno">9.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 311: <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
312: <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 313:
314: <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 315: <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>,
316: <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 317: <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 318: <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 319:
1.373 mike 320: <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1 mike 321:
322: <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 323: noscript don't count as raw text for syntax purposes -->
1.1 mike 324:
1.373 mike 325: <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1 mike 326:
1.159 mike 327: <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 328:
1.373 mike 329: <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1 mike 330:
331: <dd>Elements from the <a href="#mathml-namespace">MathML namespace</a>
332: and the <a href="#svg-namespace">SVG namespace</a>.</dd>
333:
1.373 mike 334: <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1 mike 335:
336: <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
337: elements.</dd>
338:
339: </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373 mike 340: and end of elements in the markup. <a href="#raw-text-elements" title="raw text
341: elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
342: elements">RCDATA</a>, and <a href="#normal-elements" title="normal
343: elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
344: begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
345: indicate where they end. The start and end tags of certain
346: <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 347: later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
348: elements</a> only have a start tag; end tags must not be
1.373 mike 349: specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
350: elements</a> must either have a start tag and an end tag, or a
351: start tag that is marked as self-closing, in which case they must
352: not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1 mike 353: start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
354: in certain cases</a>) and just before the end tag (which again,
355: <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
356: cases</a>). The exact allowed contents of each individual element
357: depends on the content model of that element, as described earlier
358: in this specification. Elements must not contain content that their
359: content model disallows. In addition to the restrictions placed on
360: the contents by those content models, however, the five types of
1.123 mike 361: 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 362: no end tag, no content can be put between the start tag and the end
1.373 mike 363: 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
364: 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
365: must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1 mike 366: There are also <a href="#cdata-rcdata-restrictions">further
1.373 mike 367: restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
368: self-closing can't have any contents (since, again, as there's no
369: end tag, no content can be put between the start tag and the end
370: tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
371: 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 372: 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 373:
374: <p>The HTML syntax does not support namespace
375: declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
376:
377: <p>For instance, consider the following HTML fragment:</p>
378:
379: <pre><p>
380: <svg>
381: <metadata>
382: <!-- this is invalid -->
383: <cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/>
384: </metadata>
385: </svg>
386: </p></pre>
387:
388: <p>The innermost element, <code title="">cdr:license</code>, is
389: actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
390: XML). In fact, as the comment in the fragment above says, the
391: fragment is actually non-conforming. This is because the SVG
392: specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
393:
394: </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 395: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
396: <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1 mike 397: content they are allowed to hold, beyond the restrictions imposed by
398: the content model and those described in this paragraph. Those
1.123 mike 399: restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1 mike 400: giving the element's name. HTML elements all have names that only
1.464 mike 401: use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
402: NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
403: Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
404: Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462 mike 405: elements</a>, may be written with any mix of lower- and uppercase
406: letters that, when converted to all-lowercase, matches the element's
1.614 mike 407: tag name; tag names are case-insensitive.</p><h5 id="start-tags"><span class="secno">9.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 408: following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588 mike 409: SIGN character (<).</li>
1.1 mike 410:
411: <li>The next few characters of a start tag must be the element's
412: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
413:
414: <li>If there are to be any attributes in the next step, there must
415: first be one or more <a href="infrastructure.html#space-character" title="space character">space
416: characters</a>.</li>
417:
418: <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
419: below. Attributes may be separated from each other by one or more
420: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
421:
422: <li>After the attributes, there may be one or more <a href="infrastructure.html#space-character" title="space character">space characters</a>. (Some attributes
423: are required to be followed by a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes section</a> below.)</li>
424:
425: <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373 mike 426: or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588 mike 427: element</a>, then there may be a single U+002F SOLIDUS character
428: (/). This character has no effect on <a href="#void-elements">void elements</a>,
429: but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
430: self-closing.</li>
1.1 mike 431:
432: <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588 mike 433: SIGN character (>).</li>
1.1 mike 434:
1.614 mike 435: </ol><h5 id="end-tags"><span class="secno">9.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 436: following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588 mike 437: SIGN character (<).</li>
1.1 mike 438:
439: <li>The second character of an end tag must be a U+002F SOLIDUS
1.588 mike 440: character (/).</li>
1.1 mike 441:
442: <li>The next few characters of an end tag must be the element's
443: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
444:
445: <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
446: character">space characters</a>.</li>
447:
1.588 mike 448: <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
449: character (>).</li>
1.1 mike 450:
1.614 mike 451: </ol><h5 id="attributes"><span class="secno">9.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 452: 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 453: one or more characters other than the <a href="infrastructure.html#space-character" title="space
454: character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
455: MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
456: (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
457: the control characters, and any characters that are not defined by
1.462 mike 458: Unicode. In the HTML syntax, attribute names, even those for
459: <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
460: and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123 mike 461: 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 462: 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 463: 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 464:
465: <dd>
466:
467: <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
468: name</a>.</p>
469:
470: <div class="example">
471:
472: <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
473: the empty attribute syntax:</p>
474:
475: <pre><input <em>disabled</em>></pre>
476:
477: </div>
478:
479: <p>If an attribute using the empty attribute syntax is to be
480: followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
481: character</a> separating the two.</p>
482:
483: </dd>
484:
1.2 mike 485: <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1 mike 486:
487: <dd>
488:
489: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
490: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
491: characters</a>, followed by a single U+003D EQUALS SIGN
492: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
493: character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
494: addition to the requirements given above for attribute values,
495: must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588 mike 496: characters</a>, any U+0022 QUOTATION MARK characters ("),
497: U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
498: characters (=), U+003C LESS-THAN SIGN characters (<), U+003E
499: GREATER-THAN SIGN characters (>), or U+0060 GRAVE ACCENT
500: characters (`), and must not be the empty string.</p>
1.463 mike 501:
502: <!-- The ` character is in this list on a temporary basis, waiting
503: for IE to fix it's parsing bug whereby it treats ` as an
504: attribute value delimiter. Otherwise, escaping software that
505: tries to be clever and not use quotes when it doesn't need to
506: could be tricked by an attacker.
507:
508: Posit a site that allows the user to input text that is used
509: verbatim in two attributes, such that the user can set the
510: first attribute's value to:
511:
512: `
513:
514: ...and the second to:
515:
516: ` onload='...payload...' end=x
517:
518: ...with the assumption that the site is going to not quote
519: the first one, and quote the second one with double quotes:
520:
521: <body title=` class="` onload='...payload...' end=x">
522:
523: In IE, this is treated as:
524:
525: <body title=' class="'
526: onload='...payload...'
527: end='x"'>
528:
529: -->
530:
1.1 mike 531:
532: <div class="example">
533:
534: <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
535: with the unquoted attribute value syntax:</p>
536:
537: <pre><input <em>value=yes</em>></pre>
538:
539: </div>
540:
541: <p>If an attribute using the unquoted attribute syntax is to be
1.101 mike 542: followed by another attribute or by the optional U+002F SOLIDUS
1.464 mike 543: 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 544: must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
545:
546: </dd>
547:
548: <dt>Single-quoted attribute value syntax</dt>
549:
550: <dd>
551:
552: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
553: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
554: characters</a>, followed by a single U+003D EQUALS SIGN
555: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
556: character">space characters</a>, followed by a single U+0027
1.588 mike 557: APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 558: addition to the requirements given above for attribute values,
1.588 mike 559: must not contain any literal U+0027 APOSTROPHE characters ('), and
560: finally followed by a second single U+0027 APOSTROPHE character
561: (').</p>
1.1 mike 562:
563: <div class="example">
564:
565: <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
566: single-quoted attribute value syntax:</p>
567:
568: <pre><input <em>type='checkbox'</em>></pre>
569:
570: </div>
571:
572: <p>If an attribute using the single-quoted attribute syntax is to
573: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
574: character</a> separating the two.</p>
575:
576: </dd>
577:
578: <dt>Double-quoted attribute value syntax</dt>
579:
580: <dd>
581:
582: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
583: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
584: characters</a>, followed by a single U+003D EQUALS SIGN
585: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
586: character">space characters</a>, followed by a single U+0022
1.588 mike 587: QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 588: addition to the requirements given above for attribute values,
1.588 mike 589: must not contain any literal U+0022 QUOTATION MARK characters ("),
590: and finally followed by a second single U+0022 QUOTATION MARK
591: character (").</p>
1.1 mike 592:
593: <div class="example">
594:
595: <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
596: double-quoted attribute value syntax:</p>
597:
598: <pre><input <em>name="be evil"</em>></pre>
599:
600: </div>
601:
602: <p>If an attribute using the double-quoted attribute syntax is to
603: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
604: character</a> separating the two.</p>
605:
606: </dd>
607:
608: </dl><p>There must never be two or more attributes on the same start tag
609: whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462 mike 610: each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
611: one of the namespaced attributes given by the local name and
612: namespace of the first and second cells of a row from the following
613: table, it must be written using the name given by the third cell
614: from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
615: </th></tr></thead><tbody><tr><td> <code title="">actuate</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:actuate</code>
616: </td></tr><tr><td> <code title="">arcrole</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:arcrole</code>
617: </td></tr><tr><td> <code title="">href</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:href</code>
618: </td></tr><tr><td> <code title="">role</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:role</code>
619: </td></tr><tr><td> <code title="">show</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:show</code>
620: </td></tr><tr><td> <code title="">title</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:title</code>
621: </td></tr><tr><td> <code title="">type</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:type</code>
622: </td></tr><tr><td> <code title="">base</code> </td><td> <a href="#xml-namespace">XML namespace</a> <!-- attr-xml-base --> </td><td> <code title="">xml:base</code>
623: </td></tr><tr><td> <code title="">lang</code> </td><td> <a href="#xml-namespace">XML namespace</a> </td><td> <code title="">xml:lang</code>
624: </td></tr><tr><td> <code title="">space</code> </td><td> <a href="#xml-namespace">XML namespace</a> </td><td> <code title="">xml:space</code>
625: </td></tr><tr><td> <code title="">xmlns</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns</code>
626: </td></tr><tr><td> <code title="">xlink</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns:xlink</code>
627: </td></tr></tbody></table><p>No other namespaced attribute can be expressed in the <a href="#syntax">the
1.614 mike 628: HTML syntax</a>.</p><h5 id="optional-tags"><span class="secno">9.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 629: is not present; it is implied, but it is still there. An HTML
1.159 mike 630: document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1 mike 631: string <code title=""><html></code> doesn't appear anywhere in
1.159 mike 632: 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
633: 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
634: tag</a> may be omitted if the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not
635: immediately followed by a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- <head> --><p>A <code><a href="semantics.html#the-head-element-0">head</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted <!--if the
1.1 mike 636: element is empty, or--> if the first thing inside the
1.159 mike 637: <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
638: tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
639: 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
640: 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 641: 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 642: 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 643: <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
644: tag is present, the parser makes <style> and <script> elements
645: between </head> and <body> end up in the <head> instead of implying
1.159 mike 646: 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
647: 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 648: 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 649: tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
650: immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422 mike 651: 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 652: tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
653: immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123 mike 654: <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 655: tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
656: immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
657: <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123 mike 658: 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 659: tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
660: immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
661: <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 662: <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306 mike 663: <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 664: <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>,
665: <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>,
666: <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>,
667: <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>,
668: <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 669: <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>,
670: element, or if there is no more content in the parent element and
1.123 mike 671: 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 672: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
673: 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 674: 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 675: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
676: 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 677: 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 678: <select>; commented out text below can handle the non-<select> case
1.123 mike 679: 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 680: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
681: <code>select</code> element and--> is immediately followed by
682: another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
683: that are ancestors of the <code>optgroup</code> element, up to and
684: including the first ancestor element that is not an
685: <code>optgroup</code> element, have no more content--> there is no
1.123 mike 686: more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1 mike 687: <select><optgroup></select>
688: <p id=x><optgroup></optgroup>x</p>
689: <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
690: <p><optgroup id=x><optgroup></optgroup>x</p>
691: <p><optgroup><optgroup id=x>x</p>
1.123 mike 692: --><!-- </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 693: tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
694: immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
695: it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123 mike 696: 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 697: first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
698: <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
699: 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 700: 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 701: <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123 mike 702: <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 703: tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
704: 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 705: 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 706: first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
707: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
708: 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
709: <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
710: tag</a> has been omitted. (It can't be omitted if the element is
1.123 mike 711: 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 712: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
713: 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 714: 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 715: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
716: immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123 mike 717: 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 718: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
719: immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123 mike 720: 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 721: tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
722: 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 723: 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 724: tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
725: 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 726: 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.614 mike 727: tag</a> must never be omitted if it has any attributes.</p><h5 id="element-restrictions"><span class="secno">9.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 728: 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 729: elements, even though these elements are technically allowed inside
730: <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
731: described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
732: 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 733: 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
734: placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1 mike 735: 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>
736: elements. This does not affect the processing of the element. The
1.304 mike 737: otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381 mike 738: <em>must</em> be included if the element's contents themselves start
739: with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
740: otherwise the leading newline in the contents would be treated like
741: the optional newline, and ignored).</p><div class="example">
1.1 mike 742: <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
743: <pre><pre>Hello</pre></pre>
744: <pre><pre><br>Hello</pre></pre>
1.614 mike 745: </div><h5 id="cdata-rcdata-restrictions"><span class="secno">9.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 746: <a href="#rcdata-elements" title="RCDATA elements">RCDATAs</a> element must not
747: contain any occurrences of the string "<code title=""></</code>"
748: (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that
1.1 mike 749: case-insensitively match the tag name of the element followed by one
750: of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM
1.304 mike 751: FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E
1.614 mike 752: GREATER-THAN SIGN (>), or U+002F SOLIDUS (/).</p><h4 id="text-0"><span class="secno">9.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 753: attributes, and comments. Text must consist of Unicode characters.
754: Text must not contain U+0000 characters. Text must not contain
1.316 mike 755: permanently undefined Unicode characters (noncharacters). Text must
756: not contain control characters other than <a href="infrastructure.html#space-character" title="space
757: character">space characters</a>. Extra constraints are placed on
758: what is and what is not allowed in text based on where the text is
1.614 mike 759: to be put, as described in the other sections.</p><h5 id="newlines"><span class="secno">9.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 760: represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
761: LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.614 mike 762: U+000A LINE FEED (LF) characters in that order.</p><h4 id="character-references"><span class="secno">9.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 763: to escape characters that couldn't otherwise legally be included in
1.588 mike 764: <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
765: (&). Following this, there are three possible kinds of character
766: references:</p><dl><dt>Named character references</dt>
1.1 mike 767:
768: <dd>The ampersand must be followed by one of the names given in the
769: <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
770: case. The name must be one that is terminated by a U+003B SEMICOLON
1.464 mike 771: character (;).</dd>
1.1 mike 772:
773:
774: <dt>Decimal numeric character reference</dt>
775:
776: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 777: character (#), followed by one or more digits in the range U+0030
778: DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
779: integer that corresponds to a Unicode code point that is allowed
780: according to the definition below. The digits must then be followed
781: by a U+003B SEMICOLON character (;).</dd>
1.1 mike 782:
783:
784: <dt>Hexadecimal numeric character reference</dt>
785:
786: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 787: character (#), which must be followed by either a U+0078 LATIN
788: SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
789: character (X), which must then be followed by one or more digits in
790: the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
791: LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
792: LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464 mike 793: representing a base-sixteen integer that corresponds to a Unicode
794: code point that is allowed according to the definition below. The
795: digits must then be followed by a U+003B SEMICOLON character
796: (;).</dd>
1.378 mike 797:
798: </dl><p>The numeric character reference forms described above are allowed
799: to reference any Unicode code point other than U+0000, permanently
800: undefined Unicode characters (noncharacters), and control characters
801: other than <a href="infrastructure.html#space-character" title="space character">space
802: characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464 mike 803: ampersand</dfn> is a U+0026 AMPERSAND character (&) that is
804: followed by some <a href="#syntax-text" title="syntax-text">text</a> other than a
805: <a href="infrastructure.html#space-character">space character</a>, a U+003C LESS-THAN SIGN character
1.614 mike 806: (<), or another U+0026 AMPERSAND character (&).</p><h4 id="cdata-sections"><span class="secno">9.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 807: the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
808: MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
809: U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
810: LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
811: SQUARE BRACKET (<code title=""><![CDATA[</code>). Following this
812: sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
813: that the text must not contain the three character sequence U+005D
814: RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
815: GREATER-THAN SIGN (<code title="">]]></code>). Finally, the CDATA
816: section must be ended by the three character sequence U+005D RIGHT
817: SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.614 mike 818: SIGN (<code title="">]]></code>).</p><h4 id="comments"><span class="secno">9.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 819: four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
820: MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title=""><!--</code>). Following this sequence, the comment may
821: have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
822: restriction that the text must not start with a single U+003E
1.588 mike 823: GREATER-THAN SIGN character (>), nor start with a U+002D
824: HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
825: (>) character, nor contain two consecutive U+002D HYPHEN-MINUS
826: characters (<code title="">--</code>), nor end with a U+002D
827: HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1 mike 828: the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123 mike 829: HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p><div class="impl">
1.1 mike 830:
1.159 mike 831: <h3 id="parsing"><span class="secno">9.2 </span>Parsing HTML documents</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 832:
833: <p><i>This section only applies to user agents, data mining tools,
834: and conformance checkers.</i></p>
835:
836: <p class="note">The rules for parsing XML documents into DOM trees
837: are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
838: syntax</a>".</p>
839:
840: <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
841: rules described in this section to generate the DOM trees. Together,
842: these rules define what is referred to as the <dfn id="html-parser">HTML
843: parser</dfn>.</p>
844:
845: <div class="note">
846:
847: <p>While the HTML syntax described in this specification bears a
848: close resemblance to SGML and XML, it is a separate language with
849: its own parsing rules.</p>
850:
1.183 mike 851: <p>Some earlier versions of HTML (in particular from HTML2 to
852: HTML4) were based on SGML and used SGML parsing rules. However, few
1.1 mike 853: (if any) web browsers ever implemented true SGML parsing for HTML
854: documents; the only user agents to strictly handle HTML as an SGML
855: application have historically been validators. The resulting
856: confusion — with validators claiming documents to have one
857: representation while widely deployed Web browsers interoperably
858: implemented a different representation — has wasted decades
859: of productivity. This version of HTML thus returns to a non-SGML
860: basis.</p>
861:
862: <p>Authors interested in using SGML tools in their authoring
863: pipeline are encouraged to use XML tools and the XML serialization
864: of HTML.</p>
865:
866: </div>
867:
868: <p>This specification defines the parsing rules for HTML documents,
869: whether they are syntactically correct or not. Certain points in the
870: parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
871: errors</dfn>. The error handling for parse errors is well-defined:
872: user agents must either act as described below when encountering
873: such problems, or must abort processing at the first error that they
874: encounter for which they do not wish to apply the rules described
875: below.</p>
876:
877: <p>Conformance checkers must report at least one parse error
878: condition to the user if one or more parse error conditions exist in
879: the document and must not report parse error conditions if none
880: exist in the document. Conformance checkers may report more than one
1.174 mike 881: parse error condition if more than one parse error condition exists
1.1 mike 882: in the document. Conformance checkers are not required to recover
883: from parse errors.</p>
884:
885: <p class="note">Parse errors are only errors with the
886: <em>syntax</em> of HTML. In addition to checking for parse errors,
887: conformance checkers will also verify that the document obeys all
888: the other conformance requirements described in this
889: specification.</p>
890:
891: <p>For the purposes of conformance checkers, if a resource is
892: determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
893: <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
894:
1.266 mike 895: </div><div class="impl">
1.1 mike 896:
1.614 mike 897: <h4 id="overview-of-the-parsing-model"><span class="secno">9.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 898:
899: <p>The input to the HTML parsing process consists of a stream of
900: Unicode characters, which is passed through a
901: <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
902: construction</a> stage. The output is a <code>Document</code>
903: object.</p>
904:
905: <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
906: support scripting</a> do not have to actually create a DOM
907: <code>Document</code> object, but the DOM tree in such cases is
908: still used as the model for the rest of the specification.</p>
909:
910: <p>In the common case, the data handled by the tokenization stage
1.159 mike 911: comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
912: 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 913:
914: <p><img alt="" src="images/parsing-model-overview.png"></p>
915:
916: <p id="nestedParsing">There is only one set of states for the
917: tokenizer stage and the tree construction stage, but the tree
918: construction stage is reentrant, meaning that while the tree
919: construction stage is handling one token, the tokenizer might be
920: resumed, causing further tokens to be emitted and processed before
921: the first token's processing is complete.</p>
922:
923: <div class="example">
924:
925: <p>In the following example, the tree construction stage will be
926: called upon to handle a "p" start tag token while handling the
927: "script" start tag token:</p>
928:
929: <pre>...
930: <script>
931: document.write('<p>');
932: </script>
933: ...</pre>
934:
935: </div>
936:
937: <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
938: level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
939: pause flag</dfn>, which must be initially set to false.</p>
940:
1.266 mike 941: </div><div class="impl">
1.1 mike 942:
1.614 mike 943: <h4 id="the-input-stream"><span class="secno">9.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 944:
945: <p>The stream of Unicode characters that comprises the input to the
946: tokenization stage will be initially seen by the user agent as a
947: stream of bytes (typically coming over the network or from the local
948: file system). The bytes encode the actual characters according to a
949: particular <em>character encoding</em>, which the user agent must
950: use to decode the bytes into characters.</p>
951:
952: <p class="note">For XML documents, the algorithm user agents must
953: use to determine the character encoding is given by the XML
1.104 mike 954: specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1 mike 955:
956:
1.614 mike 957: <h5 id="determining-the-character-encoding"><span class="secno">9.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 958:
959: <p>In some cases, it might be impractical to unambiguously determine
960: the encoding before parsing the document. Because of this, this
961: specification provides for a two-pass mechanism with an optional
962: pre-scan. Implementations are allowed, as described below, to apply
963: a simplified parsing algorithm to whatever bytes they have available
964: before beginning to parse the document. Then, the real parser is
965: started, using a tentative encoding derived from this pre-parse and
966: other out-of-band metadata. If, while the document is being loaded,
967: the user agent discovers an encoding declaration that conflicts with
968: this information, then the parser can get reinvoked to perform a
969: parse of the document with the real encoding.</p>
970:
971: <p id="documentEncoding">User agents must use the following
972: algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
973: the character encoding to use when decoding a document in the first
974: pass. This algorithm takes as input any out-of-band metadata
975: available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
976: and all the bytes available so far, and returns an encoding and a
977: <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
978: confidence is either <i>tentative</i>, <i>certain</i>, or
979: <i>irrelevant</i>. The encoding used, and whether the confidence in
980: that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
981: determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
982: encoding is necessary, e.g. because the parser is operating on a
983: stream of Unicode characters and doesn't have to use an encoding at
984: all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
985: <i>irrelevant</i>.</p>
986:
987: <ol><li><p>If the transport layer specifies an encoding, and it is
988: supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
989: <i>certain</i>, and abort these steps.</p></li>
990:
991: <li><p>The user agent may wait for more bytes of the resource to be
992: available, either in this step or at any later step in this
993: algorithm. For instance, a user agent might wait 500ms or 512
994: bytes, whichever came first. In general preparsing the source to
995: find the encoding improves performance, as it reduces the need to
996: throw away the data structures used when parsing upon finding the
997: encoding information. However, if the user agent delays too long to
998: obtain data to determine the encoding, then the cost of the delay
999: could outweigh any performance improvements from the
1000: preparse.</p></li>
1001:
1002: <li><p>For each of the rows in the following table, starting with
1003: the first one and going down, if there are as many or more bytes
1004: available than the number of bytes in the first column, and the
1005: first bytes of the file match the bytes given in the first column,
1006: then return the encoding given in the cell in the second column of
1007: that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1008: <i>certain</i>, and abort these steps:</p>
1009:
1010: <!-- this table is present in several forms in this file; keep them in sync -->
1011: <table><thead><tr><th>Bytes in Hexadecimal
1012: </th><th>Encoding
1013: </th></tr></thead><tbody><!-- nobody uses this
1014: <tr>
1015: <td>00 00 FE FF
1016: <td>UTF-32BE
1017: <tr>
1018: <td>FF FE 00 00
1019: <td>UTF-32LE
1020: --><tr><td>FE FF
1021: </td><td>UTF-16BE
1022: </td></tr><tr><td>FF FE
1023: </td><td>UTF-16LE
1024: </td></tr><tr><td>EF BB BF
1025: </td><td>UTF-8
1026: <!-- nobody uses this
1027: <tr>
1028: <td>DD 73 66 73
1029: <td>UTF-EBCDIC
1030: -->
1031: </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
1032: (BOMs).</p></li>
1033:
1034: <li><p>Otherwise, the user agent will have to search for explicit
1035: character encoding information in the file itself. This should
1036: proceed as follows:
1037:
1038: </p><p>Let <var title="">position</var> be a pointer to a byte in the
1039: input stream, initially pointing at the first byte. If at any
1040: point during these substeps the user agent either runs out of
1041: bytes or decides that scanning further bytes would not be
1042: efficient, then skip to the next step of the overall character
1043: encoding detection algorithm. User agents may decide that scanning
1044: <em>any</em> bytes is not efficient, in which case these substeps
1045: are entirely skipped.</p>
1046:
1047: <p>Now, repeat the following "two" steps until the algorithm
1048: aborts (either because user agent aborts, as described above, or
1049: because a character encoding is found):</p>
1050:
1051: <ol><li><p>If <var title="">position</var> points to:</p>
1052:
1053: <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '<!--')</dt>
1054: <dd>
1055:
1056: <p>Advance the <var title="">position</var> pointer so that it
1057: points at the first 0x3E byte which is preceded by two 0x2D
1058: bytes (i.e. at the end of an ASCII '-->' sequence) and comes
1059: after the 0x3C byte that was found. (The two 0x2D bytes can be
1060: the same as the those in the '<!--' sequence.)</p>
1061:
1062: </dd>
1063:
1064: <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>
1065: <dd>
1066:
1067: <ol><li><p>Advance the <var title="">position</var> pointer so
1068: that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
1069: 0x2F byte (the one in sequence of characters matched
1070: above).</p></li>
1071:
1072: <li><p><a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get
1073: an attribute</a> and its value. If no attribute was
1074: sniffed, then skip this inner set of steps, and jump to the
1075: second step in the overall "two step" algorithm.</p></li>
1076:
1077: <li><p>If the attribute's name is neither "<code title="">charset</code>" nor "<code title="">content</code>",
1078: then return to step 2 in these inner steps.</p></li>
1079:
1080: <li><p>If the attribute's name is "<code title="">charset</code>", let <var title="">charset</var> be
1081: the attribute's value, interpreted as a character
1082: encoding.</p></li>
1083:
1084: <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
1085: extracting an encoding from a Content-Type</a>, giving the
1086: attribute's value as the string to parse. If an encoding is
1087: returned, let <var title="">charset</var> be that
1088: encoding. Otherwise, return to step 2 in these inner
1089: steps.</p></li>
1090:
1091: <li><p>If <var title="">charset</var> is a UTF-16 encoding,
1092: change the value of <var title="">charset</var> to
1093: UTF-8.</p></li>
1094:
1095: <li><p>If <var title="">charset</var> is a supported
1096: character encoding, then return the given encoding, with
1097: <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1098: <i>tentative</i>, and abort all these steps.</p></li>
1099:
1100: <li><p>Otherwise, return to step 2 in these inner
1101: steps.</p></li>
1102:
1103: </ol></dd>
1104:
1.464 mike 1105: <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 1106: <dd>
1107:
1108: <ol><li><p>Advance the <var title="">position</var> pointer so
1109: that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
1110: 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464 mike 1111: (ASCII >) byte.</p></li>
1.1 mike 1112:
1113: <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
1114: attribute</a> until no further attributes can be found,
1115: then jump to the second step in the overall "two step"
1116: algorithm.</p></li>
1117:
1118: </ol></dd>
1119:
1120: <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '<!')</dt>
1121: <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '</')</dt>
1122: <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '<?')</dt>
1123: <dd>
1124:
1125: <p>Advance the <var title="">position</var> pointer so that it
1.464 mike 1126: points at the first 0x3E byte (ASCII >) that comes after the
1.1 mike 1127: 0x3C byte that was found.</p>
1128:
1129: </dd>
1130:
1131: <dt>Any other byte</dt>
1132: <dd>
1133:
1134: <p>Do nothing with that byte.</p>
1135:
1136: </dd>
1137:
1138: </dl></li>
1139:
1140: <li>Move <var title="">position</var> so it points at the next
1141: byte in the input stream, and return to the first step of this
1142: "two step" algorithm.</li>
1143:
1144: </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
1145: attribute</dfn>, it means doing this:</p>
1146:
1147: <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
1148: (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464 mike 1149: 0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1 mike 1150: substep.</p></li>
1151:
1152: <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464 mike 1153: >), then abort the "get an attribute" algorithm. There isn't
1.1 mike 1154: one.</p></li>
1155:
1156: <li><p>Otherwise, the byte at <var title="">position</var> is the
1157: start of the attribute name. Let <var title="">attribute
1158: name</var> and <var title="">attribute value</var> be the empty
1159: string.</p></li>
1160:
1161: <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
1162:
1.464 mike 1163: <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1 mike 1164: name</var> is longer than the empty string</dt>
1165:
1166: <dd>Advance <var title="">position</var> to the next byte and
1167: jump to the step below labeled <i>value</i>.</dd>
1168:
1169: <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1170: FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
1171:
1172: <dd>Jump to the step below labeled <i>spaces</i>.</dd>
1173:
1.464 mike 1174: <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII >)</dt>
1.1 mike 1175:
1176: <dd>Abort the "get an attribute" algorithm. The attribute's
1177: name is the value of <var title="">attribute name</var>, its
1178: value is the empty string.</dd>
1179:
1.464 mike 1180: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1181: Z)</dt>
1.1 mike 1182:
1183: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1184: name</var> (where <var title="">b</var> is the value of the
1185: byte at <var title="">position</var>).</dd>
1186:
1187: <dt>Anything else</dt>
1188:
1189: <dd>Append the Unicode character with the same code point as the
1190: value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
1191: bytes outside the ASCII range are handled here, since only
1192: ASCII characters can contribute to the detection of a character
1193: encoding.)</dd>
1194:
1195: </dl></li>
1196:
1197: <li><p>Advance <var title="">position</var> to the next byte and
1198: return to the previous step.</p></li>
1199:
1200: <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1201: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1202: advance <var title="">position</var> to the next byte, then,
1203: repeat this step.</p></li>
1204:
1205: <li><p>If the byte at <var title="">position</var> is
1.464 mike 1206: <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1 mike 1207: algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
1208: string.</p></li>
1209:
1210: <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464 mike 1211: =) byte.</p></li>
1.1 mike 1212:
1213: <li><p><i>Value:</i> If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1214: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1215: advance <var title="">position</var> to the next byte, then,
1216: repeat this step.</p></li>
1217:
1218: <li><p>Process the byte at <var title="">position</var> as
1219: follows:</p>
1220:
1.464 mike 1221: <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1 mike 1222:
1223: <dd>
1224:
1225: <ol><li>Let <var title="">b</var> be the value of the byte at
1226: <var title="">position</var>.</li>
1227:
1228: <li>Advance <var title="">position</var> to the next
1229: byte.</li>
1230:
1231: <li>If the value of the byte at <var title="">position</var>
1232: is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
1233: an attribute" algorithm. The attribute's name is the value of
1234: <var title="">attribute name</var>, and its value is the
1235: value of <var title="">attribute value</var>.</li>
1236:
1.464 mike 1237: <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
1238: 0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1 mike 1239: than the value of the byte at <var title="">position</var>.</li>
1240:
1241: <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
1242: the value of the byte at <var title="">position</var>.</li>
1243:
1244: <li>Return to the second step in these substeps.</li>
1245:
1246: </ol></dd>
1247:
1.464 mike 1248: <dt>If it is 0x3E (ASCII >)</dt>
1.1 mike 1249:
1250: <dd>Abort the "get an attribute" algorithm. The attribute's
1251: name is the value of <var title="">attribute name</var>, its
1252: value is the empty string.</dd>
1253:
1254:
1.464 mike 1255: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1256: Z)</dt>
1.1 mike 1257:
1258: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1259: value</var> (where <var title="">b</var> is the value of the
1260: byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
1261:
1262: <dt>Anything else</dt>
1263:
1264: <dd>Append the Unicode character with the same code point as the
1265: 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>
1266:
1267: </dl></li>
1268:
1269: <li><p>Process the byte at <var title="">position</var> as
1270: follows:</p>
1271:
1272: <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1273: FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464 mike 1274: >)</dt>
1.1 mike 1275:
1276: <dd>Abort the "get an attribute" algorithm. The attribute's
1277: name is the value of <var title="">attribute name</var> and its
1278: value is the value of <var title="">attribute value</var>.</dd>
1279:
1.464 mike 1280: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1281: Z)</dt>
1.1 mike 1282:
1283: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1284: value</var> (where <var title="">b</var> is the value of the
1285: byte at <var title="">position</var>).</dd>
1286:
1287: <dt>Anything else</dt>
1288:
1289: <dd>Append the Unicode character with the same code point as the
1290: value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
1291:
1292: </dl></li>
1293:
1294: <li><p>Advance <var title="">position</var> to the next byte and
1295: return to the previous step.</p></li>
1296:
1297: </ol><p>For the sake of interoperability, user agents should not use a
1298: pre-scan algorithm that returns different results than the one
1299: described above. (But, if you do, please at least let us know, so
1300: that we can improve this algorithm and benefit everyone...)</p>
1301:
1302: </li>
1303:
1304: <li><p>If the user agent has information on the likely encoding for
1305: this page, e.g. based on the encoding of the page when it was last
1306: visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1307: <i>tentative</i>, and abort these steps.</p></li>
1308:
1.322 mike 1309: <li>
1310:
1311: <p>The user agent may attempt to autodetect the character encoding
1312: from applying frequency analysis or other algorithms to the data
1.568 mike 1313: stream. Such algorithms may use information about the resource
1314: other than the resource's contents, including the address of the
1315: resource. If autodetection succeeds in determining a character
1.322 mike 1316: encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1317: <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
1318:
1319: <p class="note">The UTF-8 encoding has a highly detectable bit
1320: pattern. Documents that contain bytes with values greater than
1321: 0x7F which match the UTF-8 pattern are very likely to be UTF-8,
1322: while documents with byte sequences that do not match it are very
1323: likely not. User-agents are therefore encouraged to search for
1.485 mike 1324: this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322 mike 1325:
1326: </li>
1.1 mike 1327:
1.501 mike 1328: <li>
1329:
1330: <p>Otherwise, return an implementation-defined or user-specified
1331: default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1332: <i>tentative</i>.</p>
1333:
1334: <p>In controlled environments or in environments where the
1335: encoding of documents can be prescribed (for example, for user
1336: agents intended for dedicated use in new networks), the
1337: comprehensive <code title="">UTF-8</code> encoding is
1338: suggested.</p>
1339:
1340: <p>In other environments, the default encoding is typically
1341: dependent on the user's locale (an approximation of the languages,
1342: and thus typically encodings, of the pages that the user is likely
1343: to frequent). The following table gives suggested defaults based
1.504 mike 1344: on the user's locale, for compatibility with legacy
1345: content. Locales are identified by BCP 47 language codes. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501 mike 1346:
1347: <!-- based on mozilla 1.9.1 localizations:
1348: http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
1349:
1.504 mike 1350: <table><thead><tr><th>Locale language
1.501 mike 1351: </th><th>Suggested default encoding
1352: </th></tr></thead><tbody><tr><td>ar
1353: </td><td>UTF-8
1354:
1355: </td></tr><tr><td>be
1356: </td><td>ISO-8859-5
1357:
1358: </td></tr><tr><td>bg
1359: </td><td>windows-1251
1360:
1361: </td></tr><tr><td>cs<!-- -CZ -->
1362: </td><td>ISO-8859-2
1363:
1364: </td></tr><tr><td>cy
1365: </td><td>UTF-8
1366:
1367: </td></tr><tr><td>fa<!-- -IR -->
1368: </td><td>UTF-8
1369:
1370: </td></tr><tr><td>he<!-- -IL -->
1371: </td><td>windows-1255
1372:
1373: </td></tr><tr><td>hr
1374: </td><td>UTF-8
1375:
1376: </td></tr><tr><td>hu<!-- -HU -->
1377: </td><td>ISO-8859-2
1378:
1379: </td></tr><tr><td>ja <!-- and ja-JP-mac -->
1380: </td><td>windows-31J <!-- Shift_JIS -->
1381:
1382: </td></tr><tr><td>kk
1383: </td><td>UTF-8
1384:
1385: </td></tr><tr><td>ko<!-- -KR -->
1386: </td><td>windows-949 <!-- EUC-KR -->
1387:
1388: </td></tr><tr><td>ku
1389: </td><td>windows-1254 <!-- ISO-8859-9 -->
1390:
1391: </td></tr><tr><td>lt
1392: </td><td>windows-1257
1393:
1394: </td></tr><tr><td>lv<!-- -LV -->
1395: </td><td>ISO-8859-13
1396:
1397: </td></tr><tr><td>mk<!-- -MK -->
1398: </td><td>UTF-8
1399:
1400: </td></tr><tr><td>or
1401: </td><td>UTF-8
1402:
1403: </td></tr><tr><td>pl<!-- -PL -->
1404: </td><td>ISO-8859-2
1405:
1406: </td></tr><tr><td>ro
1407: </td><td>UTF-8
1408:
1409: </td></tr><tr><td>ru
1410: </td><td>windows-1251
1411:
1412: </td></tr><tr><td>sk
1413: </td><td>windows-1250
1414:
1415: </td></tr><tr><td>sl
1416: </td><td>ISO-8859-2
1417:
1418: </td></tr><tr><td>sr
1419: </td><td>UTF-8
1420:
1421: </td></tr><tr><td>th
1422: </td><td>windows-874 <!-- TIS-620 -->
1423:
1424: </td></tr><tr><td>tr<!-- -TR -->
1425: </td><td>windows-1254 <!-- ISO-8859-9 -->
1426:
1.503 mike 1427: </td></tr><tr><td>uk
1.501 mike 1428: </td><td>windows-1251
1429:
1430: </td></tr><tr><td>vi
1431: </td><td>UTF-8
1432:
1433: </td></tr><tr><td>zh-CN
1434: </td><td>GB18030
1435:
1436: </td></tr><tr><td>zh-TW
1437: </td><td>Big5
1438:
1439: </td></tr><tr><td>All other locales
1440: </td><td>windows-1252
1441:
1442: </td></tr></tbody></table></li>
1.1 mike 1443:
1444: </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
1445: be set to the value returned from this algorithm, at the same time
1446: as the user agent uses the returned value to select the decoder to
1447: use for the input stream.</p>
1448:
1.582 mike 1449: <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
1450: of the HTTP specification, which requires that the encoding be
1451: assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1452: encoding declaration</a> to the contrary, and of the RFC 2046,
1453: which requires that the encoding be assumed to be US-ASCII in the
1454: absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
1455: contrary. This specification's third approach is motivated by a
1456: desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
1457:
1.1 mike 1458:
1.614 mike 1459: <h5 id="character-encodings-0"><span class="secno">9.2.2.2 </span>Character encodings</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 1460:
1.237 mike 1461: <p>User agents must at a minimum support the UTF-8 and Windows-1252
1462: encodings, but may support more.</p>
1463:
1464: <p class="note">It is not unusual for Web browsers to support dozens
1465: if not upwards of a hundred distinct character encodings.</p>
1466:
1.365 mike 1467: <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
1468: every character encoding they support, and should support all the
1469: IANA-registered names and aliases of every character encoding they
1470: support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237 mike 1471:
1472: <p>When comparing a string specifying a character encoding with the
1473: name or alias of a character encoding to determine if they are
1474: 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
1475: then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1476: case-insensitive</a> manner.</p>
1477:
1.539 mike 1478: <hr><p>When a user agent would otherwise use an encoding given in the
1.237 mike 1479: first column of the following table to either convert content to
1480: Unicode characters or convert Unicode characters to bytes, it must
1481: instead use the encoding given in the cell in the second column of
1482: the same row. When a byte or sequence of bytes is treated
1483: differently due to this encoding aliasing, it is said to have been
1484: <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
1485:
1486: <table><caption>Character encoding overrides</caption>
1487: <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
1488: </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
1489: <a href="references.html#refsEUCKR">[EUCKR]</a>
1490: <a href="references.html#refsWIN949">[WIN949]</a>
1491: </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
1492: <a href="references.html#refsRFC1345">[RFC1345]</a>
1493: <a href="references.html#refsGBK">[GBK]</a>
1494: </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
1495: <a href="references.html#refsRFC1345">[RFC1345]</a>
1496: <a href="references.html#refsGBK">[GBK]</a>
1497: </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
1498: <a href="references.html#refsRFC1345">[RFC1345]</a>
1499: <a href="references.html#refsWIN1252">[WIN1252]</a>
1500: </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
1501: <a href="references.html#refsRFC1345">[RFC1345]</a>
1502: <a href="references.html#refsWIN1254">[WIN1254]</a>
1503: </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
1504: <a href="references.html#refsISO885911">[ISO885911]</a>
1505: <a href="references.html#refsWIN874">[WIN874]</a>
1506: </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
1507: <a href="references.html#refsRFC1345">[RFC1345]</a>
1508: <a href="references.html#refsWIN949">[WIN949]</a>
1509: </td></tr><tr><td> Shift_JIS </td><td> windows-31J </td><td>
1510: <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
1511: <a href="references.html#refsWIN31J">[WIN31J]</a>
1512: </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
1513: <a href="references.html#refsTIS620">[TIS620]</a>
1514: <a href="references.html#refsWIN874">[WIN874]</a>
1515: </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
1516: <a href="references.html#refsRFC1345">[RFC1345]</a>
1517: <a href="references.html#refsWIN1252">[WIN1252]</a>
1518: </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
1519: encodings according to the table above is a <a href="introduction.html#willful-violation">willful
1520: violation</a> of the W3C Character Model specification, motivated
1521: by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
1522:
1523: <p>When a user agent is to use the UTF-16 encoding but no BOM has
1524: been found, user agents must default to UTF-16LE.</p>
1525:
1526: <p class="note">The requirement to default UTF-16 to LE rather than
1527: BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581 mike 1528: desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237 mike 1529:
1530: <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
1531: 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>
1532:
1533: <p>Support for encodings based on EBCDIC is not recommended. This
1534: encoding is rarely used for publicly-facing Web content.</p>
1535:
1536: <p>Support for UTF-32 is not recommended. This encoding is rarely
1537: used, and frequently implemented incorrectly.</p>
1538:
1539: <p class="note">This specification does not make any attempt to
1540: support EBCDIC-based encodings and UTF-32 in its algorithms; support
1541: and use of these encodings can thus lead to unexpected behavior in
1542: implementations of this specification.</p>
1543:
1544:
1545:
1.614 mike 1546: <h5 id="preprocessing-the-input-stream"><span class="secno">9.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 1547:
1548: <p>Given an encoding, the bytes in the input stream must be
1549: converted to Unicode characters for the tokenizer, as described by
1550: the rules for that encoding, except that the leading U+FEFF BYTE
1551: ORDER MARK character, if any, must not be stripped by the encoding
1552: layer (it is stripped by the rule below).</p> <!-- this is to
1553: prevent two leading BOMs from being both stripped, once by the
1554: decoder, and once by the parser -->
1555:
1556: <p>Bytes or sequences of bytes in the original byte stream that
1.393 mike 1557: could not be converted to Unicode code points must be converted to
1558: U+FFFD REPLACEMENT CHARACTERs.</p>
1.1 mike 1559:
1560: <p class="note">Bytes or sequences of bytes in the original byte
1561: stream that did not conform to the encoding specification
1562: (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
1563: errors that conformance checkers are expected to report.</p>
1564:
1.438 mike 1565: <p>Any byte or sequence of bytes in the original byte stream that is
1566: <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1 mike 1567: error</a>.</p>
1568:
1569: <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
1570: any are present.</p>
1571:
1.300 mike 1572: <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
1573: character regardless of whether that character was used to determine
1574: the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
1575: motivated by a desire to increase the resilience of user agents in
1576: the face of naïve transcoders.</p>
1577:
1.316 mike 1578: <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315 mike 1579: U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
1580: them to suddenly turn into codepoints when they go through a UTF-16
1581: pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316 mike 1582: CHARACTERs. Any occurrences of such characters and code points are
1583: <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1 mike 1584:
1585: <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
1586: <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
1587: CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315 mike 1588: <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
1589: to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
1590: U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
1591: U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
1592: U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
1593: U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
1594: U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316 mike 1595: errors</a>. These are all control characters or permanently
1596: undefined Unicode characters (noncharacters).</p>
1.1 mike 1597:
1598: <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
1599: characters are treated specially. Any CR characters that are
1600: followed by LF characters must be removed, and any CR characters not
1601: followed by LF characters must be converted to LF characters. Thus,
1602: newlines in HTML DOMs are represented by LF characters, and there
1603: are never any CR characters in the input to the
1604: <a href="#tokenization">tokenization</a> stage.</p>
1605:
1606: <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
1607: input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
1608: the <i><a href="#next-input-character">next input character</a></i> is the first character in the
1609: input. The <dfn id="current-input-character">current input character</dfn> is the last character
1610: to have been <i><a href="#consumed">consumed</a></i>.</p>
1611:
1612: <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
1613: character or just before the end of the input stream) where content
1.159 mike 1614: 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 1615: inserted. The insertion point is relative to the position of the
1616: character immediately after it, it is not an absolute offset into
1617: the input stream. Initially, the insertion point is
1.10 mike 1618: undefined.</p>
1.1 mike 1619:
1620: <p>The "EOF" character in the tables below is a conceptual character
1621: representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159 mike 1622: is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1 mike 1623: <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159 mike 1624: 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 1625: consumed. Otherwise, the "EOF" character is not a real character in
1626: the stream, but rather the lack of any further characters.</p>
1627:
1628:
1.614 mike 1629: <h5 id="changing-the-encoding-while-parsing"><span class="secno">9.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 1630:
1631: <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
1632: encoding</dfn>, it must run the following steps. This might happen
1633: if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
1634: failed to find an encoding, or if it found an encoding that was not
1635: the actual encoding of the file.</p>
1636:
1637: <ol><li>If the new encoding is identical or equivalent to the encoding
1638: that is already being used to interpret the input stream, then set
1639: the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1640: <i>certain</i> and abort these steps. This happens when the
1641: encoding information found in the file matches what the
1642: <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
1643: encoding, and in the second pass through the parser if the first
1644: pass found that the encoding sniffing algorithm described in the
1645: earlier section failed to find the right encoding.</li>
1646:
1647: <li>If the encoding that is already being used to interpret the
1648: input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1649: <i>certain</i> and abort these steps. The new encoding is ignored;
1650: if it was anything but the same encoding, then it would be clearly
1651: incorrect.</li>
1652:
1653: <li>If the new encoding is a UTF-16 encoding, change it to
1654: UTF-8.</li>
1655:
1656: <li>If all the bytes up to the last byte converted by the current
1657: decoder have the same Unicode interpretations in both the current
1658: encoding and the new encoding, and if the user agent supports
1659: changing the converter on the fly, then the user agent may change
1660: to the new converter for the encoding on the fly. Set the
1661: <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
1662: convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1663: <i>certain</i>, and abort these steps.</li>
1664:
1665: <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
1666: <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
1667: browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
1668: sniffing algorithm</a> and instead just set the encoding to the
1669: new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1670: <i>certain</i>. Whenever possible, this should be done without
1671: actually contacting the network layer (the bytes should be
1672: re-parsed from memory), even if, e.g., the document is marked as
1673: not being cacheable. If this is not possible and contacting the
1674: network layer would involve repeating a request that uses a method
1675: other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
1676: equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1677: <i>certain</i> and ignore the new encoding. The resource will be
1678: misinterpreted. User agents may notify the user of the situation,
1679: to aid in application development.</li>
1680:
1.266 mike 1681: </ol></div><div class="impl">
1682:
1.614 mike 1683: <h4 id="parse-state"><span class="secno">9.2.3 </span>Parse state</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 1684:
1.614 mike 1685: <h5 id="the-insertion-mode"><span class="secno">9.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 1686:
1687: <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
1688: the primary operation of the tree construction stage.</p>
1689:
1690: <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
1691: "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
1692: "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
1693: "<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 1694: "<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 1695: "<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>",
1696: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
1697: "<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
1698: table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
1699: foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
1700: body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
1701: frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
1702: frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
1703: after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
1704: frameset</a>" during the course of the parsing, as described in
1705: the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
1706: how tokens are processed and whether CDATA sections are
1707: supported.</p>
1708:
1709: <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
1710: head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
1711: body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
1712: table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
1713: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
1714: "<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
1715: that the other modes defer to them at various times. When the
1716: algorithm below says that the user agent is to do something
1717: "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
1718: mode", where <var title="">m</var> is one of these modes, the user
1719: agent must use the rules described under the <var title="">m</var>
1720: <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
1721: <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>
1722: to a new value.</p>
1723:
1724: <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540 mike 1725: mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
1726: text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
1727: is also set. This is the insertion mode to which the tree
1728: construction stage will return.</p>
1.1 mike 1729:
1730: <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
1731: mode: in foreign content">in foreign content</a>", the
1732: <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
1733: is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
1734: foreign content">in foreign content</a>" mode to handle HTML
1735: (i.e. not foreign) content.</p>
1736:
1737: <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
1738: mode appropriately</dfn>, it means the UA must follow these
1739: steps:</p>
1740:
1741: <ol><li>Let <var title="">last</var> be false.</li>
1742:
1.604 mike 1743: <li>Let <var title="">foreign</var> be false.</li>
1744:
1.1 mike 1745: <li>Let <var title="">node</var> be the last node in the
1746: <a href="#stack-of-open-elements">stack of open elements</a>.</li>
1747:
1.604 mike 1748: <li><i>Loop</i>: If <var title="">node</var> is the first node in
1749: the stack of open elements, then set <var title="">last</var> to
1750: 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 1751:
1752: <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604 mike 1753: 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
1754: step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1 mike 1755:
1756: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
1757: <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
1758: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.604 mike 1759: mode: in cell">in cell</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1760:
1761: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
1762: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.604 mike 1763: mode: in row">in row</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1764:
1765: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
1766: <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
1767: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.604 mike 1768: table body">in table body</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1769:
1770: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604 mike 1771: 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
1772: the step marked <i title="">end</i>.</li>
1.1 mike 1773:
1774: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
1775: 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 1776: jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1777: case</a>)</li>
1.1 mike 1778:
1779: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604 mike 1780: 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
1781: step marked <i title="">end</i>.</li>
1.1 mike 1782:
1.159 mike 1783: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604 mike 1784: 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
1785: the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1786: case</a>)</li> <!-- This is only here for now in case people
1787: think that the spec accidentally omitted it and try to "fix"
1788: it. Note that noscript-in-head is also handled this way. This is
1789: all intentional. The only thing it doesn't handle is the
1790: scripting-disabled fragment parsing case for a <head> element
1791: containing a <noscript> which itself contains something other than
1792: a <link> or a <style> element; you'd expect that to break out of
1793: the <noscript> but it doesn't. This is an edge case that doesn't
1794: affect the spec, since the algorithm for fragment parsing is only
1795: used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
1796: scripting is enabled. -->
1.1 mike 1797:
1.159 mike 1798: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604 mike 1799: 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
1800: step marked <i title="">end</i>.</li>
1.1 mike 1801:
1.5 mike 1802: <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604 mike 1803: 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
1804: the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1805: case</a>)</li>
1.1 mike 1806:
1.159 mike 1807: <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333 mike 1808: then <!--: if the <span><code title="">head</code> element
1809: pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
1810: to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
1811: head</a>"<!--, otherwise, switch the <span>insertion mode</span>
1812: to "<span title="insertion mode: after head">after head</span>".-->
1.604 mike 1813: Then, <!-- in either case, --> jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li> <!-- if the
1814: head element pointer can ever be non-null when we're going through
1815: these steps, we'll need to uncomment out the commented-out bits -->
1816:
1817: <li>If <var title="">node</var> is an element from the <a href="#mathml-namespace">MathML
1818: namespace</a> or the <a href="#svg-namespace">SVG namespace</a>, then set the
1819: <var title="">foreign</var> flag to true.</li>
1.1 mike 1820:
1821: <li>If <var title="">last</var> is true, then switch the
1822: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.604 mike 1823: 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 1824:
1825: <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
1826: elements</a>.</li>
1827:
1.604 mike 1828: <li>Return to the step marked <i>loop</i>.</li>
1829:
1830: <li><i>End</i>: If <var title="">foreign</var> is true, switch the
1831: <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
1832: <a href="#insertion-mode">insertion mode</a> is set to, and switch the
1833: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
1834: foreign content">in foreign content</a>".</li>
1.1 mike 1835:
1.614 mike 1836: </ol><h5 id="the-stack-of-open-elements"><span class="secno">9.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 1837:
1838: <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
1839: stack grows downwards; the topmost node on the stack is the first
1840: one added to the stack, and the bottommost node of the stack is the
1841: most recently added node in the stack (notwithstanding when the
1842: stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
1843:
1844: <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
1845: html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159 mike 1846: <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1 mike 1847: stack.</p>
1848:
1849: <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159 mike 1850: elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1 mike 1851: element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
1852: parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
1853: case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
1854: html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
1855:
1.159 mike 1856: <p>The <code><a href="semantics.html#the-html-element-0">html</a></code> node, however it is created, is the topmost
1.1 mike 1857: node of the stack. It never gets popped off the stack.</p>
1858:
1859: <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
1860: stack.</p>
1861:
1862: <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
1863: element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
1864: 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
1865: open elements</a> (<a href="#fragment-case">fragment case</a>), then the
1866: <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159 mike 1867: of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1 mike 1868:
1869: <p>Elements in the stack fall into the following categories:</p>
1870:
1871: <dl><dt><dfn id="special">Special</dfn></dt>
1872:
1873: <dd><p>The following HTML elements have varying levels of special
1874: 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>,
1875: <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.5 mike 1876: <code><a href="obsolete.html#basefont">basefont</a></code>, <code>bgsound</code>,
1.159 mike 1877: <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 1878: <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.86 mike 1879: <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID--><code>datagrid</code>,
1.422 mike 1880: <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>,
1881: <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>,
1882: <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="text-level-semantics.html#the-figure-element">figure</a></code>,
1883: <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>,
1884: <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>,
1885: <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>,
1886: <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>,
1887: <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>,
1888: (commented out because this isn't an element that can end up on the
1889: stack, so it doesn't matter) --> <code><a href="text-level-semantics.html#the-img-element">img</a></code>,
1890: <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>,
1891: <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>,
1892: <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>,
1893: <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>,
1894: <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>,
1895: <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 1896: <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>,
1897: <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>,
1898: <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>,
1899: <code>wbr</code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1 mike 1900:
1901: <dt><dfn id="scoping">Scoping</dfn></dt>
1902: <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
1903: an element in scope">scopes</a> for various parts of the
1.5 mike 1904: 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 1905: <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>,
1906: <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 1907: <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's <code>foreignObject</code>.</p></dd>
1908:
1909: <dt><dfn id="formatting">Formatting</dfn></dt>
1910: <dd><p>The following HTML elements are those that end up in the
1911: <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 1912: <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>,
1913: <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>,
1914: <code>nobr</code>, <code><a href="obsolete.html#s">s</a></code>, <code><a href="text-level-semantics.html#the-small-element">small</a></code>,
1915: <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
1916: <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1 mike 1917:
1918: <dt><dfn id="phrasing">Phrasing</dfn></dt>
1919: <dd><p>All other elements found while parsing an HTML
1920: document.</p></dd>
1921:
1.234 mike 1922: </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
1923: specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
1924: match state:</p>
1.1 mike 1925:
1926: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
1927: node</a> (the bottommost node of the stack).</p></li>
1928:
1929: <li><p>If <var title="">node</var> is the target node, terminate in
1930: a match state.</p></li>
1931:
1.234 mike 1932: <li><p>Otherwise, if <var title="">node</var> is one of the element
1933: types in <var title="">list</var>, terminate in a failure
1934: state.</p></li>
1.1 mike 1935:
1936: <li><p>Otherwise, set <var title="">node</var> to the previous
1937: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
1938: 2. (This will never fail, since the loop will always terminate in
1939: the previous step if the top of the stack — an
1.159 mike 1940: <code><a href="semantics.html#the-html-element-0">html</a></code> element — is reached.)</p></li>
1.1 mike 1941:
1.234 mike 1942: </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
1943: it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
1944: of the following element types:</p>
1945:
1946: <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
1947: <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
1948: <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.) -->
1949: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
1950: <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
1951: <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
1952: <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
1953: <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
1954: <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
1955: <li><code title="">foreignObject</code> in the SVG namespace</li>
1956: </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
1957: item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
1958: scope</a> consisting of the following element types:</p>
1959:
1960: <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
1961: in scope</a></i> algorithm.</li>
1962: <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
1963: <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
1964: </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
1965: scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
1966: scope</a> consisting of the following element types:</p>
1967:
1968: <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.) -->
1969: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
1970: </ul><p>Nothing happens if at any time any of the elements in the
1.1 mike 1971: <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
1972: or removed from, the <code>Document</code> tree. In particular, the
1973: stack is not changed in this situation. This can cause, amongst
1974: other strange effects, content to be appended to nodes that are no
1975: longer in the DOM.</p>
1976:
1977: <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
1978: the stack is manipulated in a random-access fashion.</p>
1979:
1980:
1.614 mike 1981: <h5 id="the-list-of-active-formatting-elements"><span class="secno">9.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 1982:
1983: <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
1984: empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
1985:
1986: <p>The list contains elements in the <a href="#formatting">formatting</a>
1987: category, and scope markers. The scope markers are inserted when
1.159 mike 1988: 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 1989: elements, marquees, table cells, and table captions, and are used to
1.5 mike 1990: prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159 mike 1991: elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1 mike 1992: tables.</p>
1993:
1994: <p class="note">The scope markers are unrelated to the concept of an
1995: element being <a href="#has-an-element-in-scope" title="has an element in scope">in
1996: scope</a>.</p>
1997:
1998: <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
1999: elements</a> is associated with the token for which it was
2000: created, so that further elements can be created for that token if
2001: necessary.</p>
2002:
2003: <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
2004: active formatting elements</dfn>, the UA must perform the following
2005: steps:</p>
2006:
2007: <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
2008: elements</a>, then there is nothing to reconstruct; stop this
2009: algorithm.</li>
2010:
2011: <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
2012: active formatting elements</a> is a marker, or if it is an
2013: element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
2014: there is nothing to reconstruct; stop this algorithm.</li>
2015:
2016: <li>Let <var title="">entry</var> be the last (most recently added)
2017: element in the <a href="#list-of-active-formatting-elements">list of active formatting
2018: elements</a>.</li>
2019:
2020: <li>If there are no entries before <var title="">entry</var> in the
2021: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
2022: 8.</li>
2023:
2024: <li>Let <var title="">entry</var> be the entry one earlier than
2025: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2026: elements</a>.</li>
2027:
2028: <li>If <var title="">entry</var> is neither a marker nor an element
2029: that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
2030: 4.</li>
2031:
2032: <li>Let <var title="">entry</var> be the element one later than
2033: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2034: elements</a>.</li>
2035:
2036: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
2037: element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
2038:
2039: <li>Append <var title="">new element</var> to the <a href="#current-node">current
2040: node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
2041: elements</a> so that it is the new <a href="#current-node">current
2042: node</a>.</li>
2043:
2044: <li>Replace the entry for <var title="">entry</var> in the list
2045: with an entry for <var title="">new element</var>.</li>
2046:
2047: <li>If the entry for <var title="">new element</var> in the
2048: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
2049: entry in the list, return to step 7.</li>
2050:
2051: </ol><p>This has the effect of reopening all the formatting elements that
2052: were opened in the current body, cell, or caption (whichever is
2053: youngest) that haven't been explicitly closed.</p>
2054:
2055: <p class="note">The way this specification is written, the
2056: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
2057: elements in chronological order with the least recently added
2058: element first and the most recently added element last (except for
2059: while steps 8 to 11 of the above algorithm are being executed, of
2060: course).</p>
2061:
2062: <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
2063: active formatting elements up to the last marker</dfn>, the UA must
2064: perform the following steps:</p>
2065:
2066: <ol><li>Let <var title="">entry</var> be the last (most recently added)
2067: entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
2068:
2069: <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
2070: formatting elements</a>.</li>
2071:
2072: <li>If <var title="">entry</var> was a marker, then stop the
2073: algorithm at this point. The list has been cleared up to the last
2074: marker.</li>
2075:
2076: <li>Go to step 1.</li>
2077:
1.614 mike 2078: </ol><h5 id="the-element-pointers"><span class="secno">9.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 2079:
2080: <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
2081: pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
2082: pointer</dfn> are both null.</p>
2083:
1.159 mike 2084: <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1 mike 2085: implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
2086: element pointer</a> gets set to point to this node.</p>
2087:
2088: <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
2089: points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
2090: whose end tag has not yet been seen. It is used to make form
2091: controls associate with forms in the face of dramatically bad
2092: markup, for historical reasons.</p>
2093:
2094:
1.614 mike 2095: <h5 id="other-parsing-state-flags"><span class="secno">9.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 2096:
2097: <p>The <dfn id="scripting-flag">scripting flag</dfn> is set to "enabled" if <a href="browsers.html#concept-n-script" title="concept-n-script">scripting was enabled</a> for the
2098: <code>Document</code> with which the parser is associated when the
2099: parser was created, and "disabled" otherwise.</p>
2100:
2101: <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
2102: when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
2103: parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
2104: don't execute in that case.</p>
2105:
2106: <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
2107: created. It is set to "not ok" after certain tokens are seen.</p>
2108:
1.266 mike 2109: </div><div class="impl">
1.1 mike 2110:
1.159 mike 2111: <h4 id="tokenization"><span class="secno">9.2.4 </span><dfn>Tokenization</dfn></h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 2112:
2113: <p>Implementations must act as if they used the following state
2114: machine to tokenize HTML. The state machine must start in the
2115: <a href="#data-state">data state</a>. Most states consume a single character,
2116: which may have various side-effects, and either switches the state
2117: machine to a new state to <em>reconsume</em> the same character, or
2118: switches it to a new state (to consume the next character), or
2119: repeats the same state (to consume the next character). Some states
2120: have more complicated behavior and can consume several characters
1.541 mike 2121: before switching to another state. In some cases, the tokenizer
2122: state is also changed by the tree construction stage.</p>
1.1 mike 2123:
1.541 mike 2124: <p>The exact behavior of certain states depends on the
2125: <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
2126: elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
2127: buffer</var></dfn> to track progress.</p>
1.1 mike 2128:
2129: <p>The output of the tokenization step is a series of zero or more
2130: of the following tokens: DOCTYPE, start tag, end tag, comment,
2131: character, end-of-file. DOCTYPE tokens have a name, a public
2132: identifier, a system identifier, and a <i>force-quirks
2133: flag</i>. When a DOCTYPE token is created, its name, public
2134: identifier, and system identifier must be marked as missing (which
2135: is a distinct state from the empty string), and the <i>force-quirks
2136: flag</i> must be set to <i>off</i> (its other state is
2137: <i>on</i>). Start and end tag tokens have a tag name, a
2138: <i>self-closing flag</i>, and a list of attributes, each of which
2139: has a name and a value. When a start or end tag token is created,
2140: its <i>self-closing flag</i> must be unset (its other state is that
2141: it be set), and its attributes list must be empty. Comment and
2142: character tokens have data.</p>
2143:
2144: <p>When a token is emitted, it must immediately be handled by the
2145: <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541 mike 2146: can affect the state of the tokenization stage, and can insert
2147: additional characters into the stream. (For example, the
1.1 mike 2148: <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159 mike 2149: using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1 mike 2150: characters into the stream being tokenized.)</p>
2151:
2152: <p>When a start tag token is emitted with its <i>self-closing
2153: flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
2154: self-closing flag">acknowledged</dfn> when it is processed by the
2155: tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
2156:
2157: <p>When an end tag token is emitted with attributes, that is a
2158: <a href="#parse-error">parse error</a>.</p>
2159:
2160: <p>When an end tag token is emitted with its <i>self-closing
2161: flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
2162:
1.541 mike 2163: <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
2164: tag name matches the tag name of the last start tag to have been
2165: emitted from this tokenizer, if any. If no start tag has been
2166: emitted from this tokenizer, then no end tag token is
2167: appropriate.</p>
2168:
1.1 mike 2169: <p>Before each step of the tokenizer, the user agent must first
2170: check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
2171: tokenizer must abort the processing of any nested invocations of the
1.479 mike 2172: tokenizer, yielding control back to the caller.</p>
1.1 mike 2173:
2174: <p>The tokenizer state machine consists of the states defined in the
2175: following subsections.</p>
2176:
1.541 mike 2177:
1.333 mike 2178: <!-- Order of the lists below is supposed to be non-error then
2179: error, by unicode, then EOF, ending with "anything else" -->
1.1 mike 2180:
1.541 mike 2181:
1.614 mike 2182: <h5 id="data-state"><span class="secno">9.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 2183:
2184: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2185:
2186: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.541 mike 2187: <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56 mike 2188: state</a>.</dd>
1.1 mike 2189:
1.541 mike 2190: <dt>U+003C LESS-THAN SIGN (<)</dt>
2191: <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
2192:
2193: <dt>EOF</dt>
2194: <dd>Emit an end-of-file token.</dd>
2195:
2196: <dt>Anything else</dt>
2197: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2198: token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2199:
1.618 mike 2200: </dl><h5 id="character-reference-in-data-state"><span class="secno">9.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>
2201:
2202: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2203: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2204:
2205: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2206: token.</p>
2207:
2208: <p>Otherwise, emit the character token that was returned.</p>
2209:
2210: <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
2211:
2212:
2213: <h5 id="rcdata-state"><span class="secno">9.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 2214:
1.541 mike 2215: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2216:
1.541 mike 2217: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.618 mike 2218: <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541 mike 2219: state</a>.</dd>
1.1 mike 2220:
2221: <dt>U+003C LESS-THAN SIGN (<)</dt>
1.541 mike 2222: <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
2223:
2224: <dt>EOF</dt>
2225: <dd>Emit an end-of-file token.</dd>
1.1 mike 2226:
1.541 mike 2227: <dt>Anything else</dt>
2228: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2229: token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 2230:
1.618 mike 2231: </dl><h5 id="character-reference-in-rcdata-state"><span class="secno">9.2.4.4 </span><dfn>Character reference in RCDATA state</dfn></h5>
2232:
2233: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2234: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2235:
2236: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2237: token.</p>
2238:
2239: <p>Otherwise, emit the character token that was returned.</p>
2240:
2241: <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
2242:
2243:
2244: <h5 id="rawtext-state"><span class="secno">9.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 2245:
1.541 mike 2246: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2247:
1.541 mike 2248: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2249: <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1 mike 2250:
2251: <dt>EOF</dt>
2252: <dd>Emit an end-of-file token.</dd>
2253:
2254: <dt>Anything else</dt>
1.541 mike 2255: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2256: token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 2257:
1.618 mike 2258: </dl><h5 id="script-data-state"><span class="secno">9.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 2259:
1.541 mike 2260: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2261:
1.541 mike 2262: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2263: <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1 mike 2264:
1.541 mike 2265: <dt>EOF</dt>
2266: <dd>Emit an end-of-file token.</dd>
1.1 mike 2267:
1.541 mike 2268: <dt>Anything else</dt>
2269: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2270: token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2271:
1.618 mike 2272: </dl><h5 id="plaintext-state"><span class="secno">9.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 2273:
1.541 mike 2274: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2275:
1.541 mike 2276: <dl class="switch"><dt>EOF</dt>
2277: <dd>Emit an end-of-file token.</dd>
1.1 mike 2278:
1.541 mike 2279: <dt>Anything else</dt>
2280: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2281: token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1 mike 2282:
1.618 mike 2283: </dl><h5 id="tag-open-state"><span class="secno">9.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 2284:
1.541 mike 2285: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2286:
1.541 mike 2287: <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
2288: <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1 mike 2289:
1.541 mike 2290: <dt>U+002F SOLIDUS (/)</dt>
2291: <dd>Switch to the <a href="#close-tag-open-state">close tag open state</a>.</dd>
1.1 mike 2292:
1.541 mike 2293: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2294: <dd>Create a new start tag token, set its tag name to the
2295: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
2296: character's code point), then switch to the <a href="#tag-name-state">tag name
2297: state</a>. (Don't emit the token yet; further details will
2298: be filled in before it is emitted.)</dd>
1.1 mike 2299:
1.541 mike 2300: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2301: <dd>Create a new start tag token, set its tag name to the
2302: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2303: name state</a>. (Don't emit the token yet; further details will
2304: be filled in before it is emitted.)</dd>
1.1 mike 2305:
1.541 mike 2306: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2307: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2308: character token and a U+003E GREATER-THAN SIGN character
2309: token. Switch to the <a href="#data-state">data state</a>.</dd>
1.1 mike 2310:
1.541 mike 2311: <dt>U+003F QUESTION MARK (?)</dt>
2312: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2313: comment state</a>.</dd>
1.1 mike 2314:
1.541 mike 2315: <dt>Anything else</dt>
2316: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2317: character token and reconsume the <a href="#current-input-character">current input
2318: character</a> in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2319:
1.618 mike 2320: </dl><h5 id="close-tag-open-state"><span class="secno">9.2.4.9 </span><dfn>Close tag open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 2321:
1.541 mike 2322: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2323:
2324: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2325: <dd>Create a new end tag token, set its tag name to the lowercase
1.541 mike 2326: version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
2327: the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1 mike 2328: state</a>. (Don't emit the token yet; further details will be
2329: filled in before it is emitted.)</dd>
2330:
2331: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541 mike 2332: <dd>Create a new end tag token, set its tag name to the
2333: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2334: name state</a>. (Don't emit the token yet; further details will
2335: be filled in before it is emitted.)</dd>
1.1 mike 2336:
2337: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2338: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
2339: state</a>.</dd>
2340:
2341: <dt>EOF</dt>
2342: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2343: character token and a U+002F SOLIDUS character token. Reconsume
2344: the EOF character in the <a href="#data-state">data state</a>.</dd>
2345:
2346: <dt>Anything else</dt>
2347: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2348: comment state</a>.</dd>
2349:
1.618 mike 2350: </dl><h5 id="tag-name-state"><span class="secno">9.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 2351:
2352: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2353:
2354: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2355: <dt>U+000A LINE FEED (LF)</dt>
2356: <dt>U+000C FORM FEED (FF)</dt>
2357: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2358: <dt>U+0020 SPACE</dt>
2359: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
2360:
2361: <dt>U+002F SOLIDUS (/)</dt>
2362: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
2363:
2364: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2365: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
2366: state</a>.</dd>
2367:
2368: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 2369: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2370: character</a> (add 0x0020 to the character's code point) to the
2371: current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
2372: state</a>.</dd>
2373:
2374: <dt>EOF</dt>
2375: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2376: <a href="#data-state">data state</a>.</dd>
2377:
2378: <dt>Anything else</dt>
2379: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2380: tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
2381:
1.618 mike 2382: </dl><h5 id="rcdata-less-than-sign-state"><span class="secno">9.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 2383: <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
2384:
2385: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2386:
2387: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2388: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2389: to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
2390:
2391: <dt>Anything else</dt>
2392: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2393: <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
2394: state</a>.</dd>
2395:
1.618 mike 2396: </dl><h5 id="rcdata-end-tag-open-state"><span class="secno">9.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 2397: <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
2398:
2399: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2400:
2401: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2402: <dd>Create a new end tag token, and set its tag name to the
2403: lowercase version of the <a href="#current-input-character">current input character</a> (add
2404: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2405: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2406: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2407: the token yet; further details will be filled in before it is
2408: emitted.)</dd>
2409:
2410: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2411: <dd>Create a new end tag token, and set its tag name to the
2412: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2413: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2414: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2415: the token yet; further details will be filled in before it is
2416: emitted.)</dd>
2417:
2418: <dt>Anything else</dt>
2419: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2420: character token, and reconsume the <a href="#current-input-character">current input
2421: character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2422:
1.618 mike 2423: </dl><h5 id="rcdata-end-tag-name-state"><span class="secno">9.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 2424: <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
2425:
2426: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2427:
2428: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2429: <dt>U+000A LINE FEED (LF)</dt>
2430: <dt>U+000C FORM FEED (FF)</dt>
2431: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2432: <dt>U+0020 SPACE</dt>
2433: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2434: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2435: state</a>. Otherwise, treat it as per the "anything else" entry
2436: below.</dd>
2437:
2438: <dt>U+002F SOLIDUS (/)</dt>
2439: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2440: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2441: state</a>. Otherwise, treat it as per the "anything else" entry
2442: below.</dd>
2443:
2444: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2445: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2446: token</a>, then emit the current tag token and switch to the
2447: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2448: else" entry below.</dd>
2449:
2450: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
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. Append the <a href="#current-input-character">current input
2454: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2455: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2456:
2457: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2458: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2459: tag token's tag name. Append the <a href="#current-input-character">current input
2460: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2461: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2462:
2463: <dt>Anything else</dt>
2464: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2465: character token, a character token for each of the characters in
2466: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2467: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2468: in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2469:
1.618 mike 2470: </dl><h5 id="rawtext-less-than-sign-state"><span class="secno">9.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 2471: <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
2472:
2473: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2474:
2475: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2476: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2477: to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
2478:
2479: <dt>Anything else</dt>
2480: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2481: <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
2482: state</a>.</dd>
2483:
1.618 mike 2484: </dl><h5 id="rawtext-end-tag-open-state"><span class="secno">9.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 2485: <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
2486:
2487: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2488:
2489: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2490: <dd>Create a new end tag token, and set its tag name to the
2491: lowercase version of the <a href="#current-input-character">current input character</a> (add
2492: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2493: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2494: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2495: the token yet; further details will be filled in before it is
2496: emitted.)</dd>
2497:
2498: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2499: <dd>Create a new end tag token, and set its tag name to the
2500: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2501: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2502: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2503: the token yet; further details will be filled in before it is
2504: emitted.)</dd>
2505:
2506: <dt>Anything else</dt>
2507: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2508: character token, and reconsume the <a href="#current-input-character">current input
2509: character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2510:
1.618 mike 2511: </dl><h5 id="rawtext-end-tag-name-state"><span class="secno">9.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 2512: <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
2513:
2514: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2515:
2516: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2517: <dt>U+000A LINE FEED (LF)</dt>
2518: <dt>U+000C FORM FEED (FF)</dt>
2519: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2520: <dt>U+0020 SPACE</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="#before-attribute-name-state">before attribute name
2523: state</a>. Otherwise, treat it as per the "anything else" entry
2524: below.</dd>
2525:
2526: <dt>U+002F SOLIDUS (/)</dt>
2527: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2528: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2529: state</a>. Otherwise, treat it as per the "anything else" entry
2530: below.</dd>
2531:
2532: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2533: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2534: token</a>, then emit the current tag token and switch to the
2535: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2536: else" entry below.</dd>
2537:
2538: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2539: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2540: character</a> (add 0x0020 to the character's code point) to the
2541: current 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="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2544:
2545: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2546: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2547: tag token's tag name. Append the <a href="#current-input-character">current input
2548: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2549: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2550:
2551: <dt>Anything else</dt>
2552: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2553: character token, a character token for each of the characters in
2554: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2555: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2556: in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2557:
1.618 mike 2558: </dl><h5 id="script-data-less-than-sign-state"><span class="secno">9.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 2559:
2560: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2561:
2562: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2563: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2564: to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
2565:
2566: <dt>U+0021 EXCLAMATION MARK (!)</dt>
2567: <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
2568: EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
2569: escape start state</a>.</dd>
2570:
2571: <dt>Anything else</dt>
2572: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2573: <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
2574: state</a>.</dd>
2575:
1.618 mike 2576: </dl><h5 id="script-data-end-tag-open-state"><span class="secno">9.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 2577: <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
2578:
2579: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2580:
2581: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2582: <dd>Create a new end tag token, and set its tag name to the
2583: lowercase version of the <a href="#current-input-character">current input character</a> (add
2584: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2585: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2586: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2587: the token yet; further details will be filled in before it is
2588: emitted.)</dd>
2589:
2590: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2591: <dd>Create a new end tag token, and set its tag name to the
2592: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2593: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2594: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2595: the token yet; further details will be filled in before it is
2596: emitted.)</dd>
2597:
2598: <dt>Anything else</dt>
2599: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2600: character token, and reconsume the <a href="#current-input-character">current input
2601: character</a> in the <a href="#script-data-state">script data state</a>.</dd>
2602:
1.618 mike 2603: </dl><h5 id="script-data-end-tag-name-state"><span class="secno">9.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 2604: <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
2605:
2606: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2607:
2608: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2609: <dt>U+000A LINE FEED (LF)</dt>
2610: <dt>U+000C FORM FEED (FF)</dt>
2611: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2612: <dt>U+0020 SPACE</dt>
2613: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2614: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2615: state</a>. Otherwise, treat it as per the "anything else" entry
2616: below.</dd>
2617:
2618: <dt>U+002F SOLIDUS (/)</dt>
2619: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2620: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2621: state</a>. Otherwise, treat it as per the "anything else" entry
2622: below.</dd>
2623:
2624: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2625: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2626: token</a>, then emit the current tag token and switch to the
2627: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2628: else" entry below.</dd>
2629:
2630: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2631: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2632: character</a> (add 0x0020 to the character's code point) to the
2633: current tag token's tag name. Append the <a href="#current-input-character">current input
2634: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2635: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2636:
2637: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2638: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2639: tag token's tag name. Append the <a href="#current-input-character">current input
2640: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2641: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2642:
2643: <dt>Anything else</dt>
2644: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2645: character token, a character token for each of the characters in
2646: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2647: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2648: in the <a href="#script-data-state">script data state</a>.</dd>
2649:
1.618 mike 2650: </dl><h5 id="script-data-escape-start-state"><span class="secno">9.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 2651:
2652: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2653:
2654: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2655: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2656: <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
2657:
2658: <dt>Anything else</dt>
2659: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2660: <a href="#script-data-state">script data state</a>.</dd>
2661:
1.618 mike 2662: </dl><h5 id="script-data-escape-start-dash-state"><span class="secno">9.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 2663:
2664: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2665:
2666: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2667: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2668: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2669:
2670: <dt>Anything else</dt>
2671: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2672: <a href="#script-data-state">script data state</a>.</dd>
2673:
1.618 mike 2674: </dl><h5 id="script-data-escaped-state"><span class="secno">9.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 2675:
2676: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2677:
2678: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2679: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2680: <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
2681:
1.542 mike 2682: <dt>U+003C LESS-THAN SIGN (<)</dt>
2683: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2684: state</a>.</p></dd>
2685:
1.541 mike 2686: <dt>EOF</dt>
2687: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2688: <a href="#data-state">data state</a>.</dd>
2689:
2690: <dt>Anything else</dt>
1.542 mike 2691: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2692: token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2693:
1.618 mike 2694: </dl><h5 id="script-data-escaped-dash-state"><span class="secno">9.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 2695:
2696: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2697:
2698: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2699: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2700: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2701:
1.542 mike 2702: <dt>U+003C LESS-THAN SIGN (<)</dt>
2703: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2704: state</a>.</p></dd>
2705:
1.541 mike 2706: <dt>EOF</dt>
2707: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2708: <a href="#data-state">data state</a>.</dd>
2709:
2710: <dt>Anything else</dt>
1.542 mike 2711: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2712: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2713:
1.618 mike 2714: </dl><h5 id="script-data-escaped-dash-dash-state"><span class="secno">9.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 2715:
2716: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2717:
2718: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2719: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
2720: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2721:
1.542 mike 2722: <dt>U+003C LESS-THAN SIGN (<)</dt>
2723: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2724: state</a>.</p></dd>
2725:
1.541 mike 2726: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2727: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
2728: <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2729:
2730: <dt>EOF</dt>
2731: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2732: <a href="#data-state">data state</a>.</dd>
2733:
2734: <dt>Anything else</dt>
1.542 mike 2735: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2736: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2737:
1.618 mike 2738: </dl><h5 id="script-data-escaped-less-than-sign-state"><span class="secno">9.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 2739:
2740: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2741:
2742: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2743: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2744: to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
2745:
2746: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2747: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2748: <a href="#current-input-character">current input character</a> as a character token. Set the
2749: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2750: lowercase version of the <a href="#current-input-character">current input character</a> (add
2751: 0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
2752: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2753: state</a>.</dd>
2754:
2755: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2756: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2757: <a href="#current-input-character">current input character</a> as a character token. Set the
2758: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2759: <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
2760: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2761: state</a>.</dd>
2762:
2763: <dt>Anything else</dt>
2764: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2765: <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
2766: escaped state</a>.</dd>
2767:
1.618 mike 2768: </dl><h5 id="script-data-escaped-end-tag-open-state"><span class="secno">9.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 2769:
2770: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2771:
2772: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2773: <dd>Create a new end tag token, and set its tag name to the
2774: lowercase version of the <a href="#current-input-character">current input character</a> (add
2775: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2776: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2777: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2778: state</a>. (Don't emit the token yet; further details will be
2779: filled in before it is emitted.)</dd>
2780:
2781: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2782: <dd>Create a new end tag token, and set its tag name to the
2783: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2784: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2785: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2786: state</a>. (Don't emit the token yet; further details will be
2787: filled in before it is emitted.)</dd>
2788:
2789: <dt>Anything else</dt>
2790: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2791: character token, and reconsume the <a href="#current-input-character">current input
2792: character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2793:
1.618 mike 2794: </dl><h5 id="script-data-escaped-end-tag-name-state"><span class="secno">9.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 2795:
2796: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2797:
2798: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2799: <dt>U+000A LINE FEED (LF)</dt>
2800: <dt>U+000C FORM FEED (FF)</dt>
2801: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2802: <dt>U+0020 SPACE</dt>
2803: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2804: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2805: state</a>. Otherwise, treat it as per the "anything else" entry
2806: below.</dd>
2807:
2808: <dt>U+002F SOLIDUS (/)</dt>
2809: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2810: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2811: state</a>. Otherwise, treat it as per the "anything else" entry
2812: below.</dd>
2813:
2814: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2815: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2816: token</a>, then emit the current tag token and switch to the
2817: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2818: else" entry below.</dd>
2819:
2820: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2821: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2822: character</a> (add 0x0020 to the character's code point) to the
2823: current tag token's tag name. Append the <a href="#current-input-character">current input
2824: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2825: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2826:
2827: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2828: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2829: tag token's tag name. Append the <a href="#current-input-character">current input
2830: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2831: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2832:
2833: <dt>Anything else</dt>
2834: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2835: character token, a character token for each of the characters in
2836: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2837: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2838: in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2839:
1.618 mike 2840: </dl><h5 id="script-data-double-escape-start-state"><span class="secno">9.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 2841:
2842: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2843:
2844: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2845: <dt>U+000A LINE FEED (LF)</dt>
2846: <dt>U+000C FORM FEED (FF)</dt>
2847: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2848: <dt>U+0020 SPACE</dt>
2849: <dt>U+002F SOLIDUS (/)</dt>
2850: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2851: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2852: 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
2853: double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
2854: data escaped state</a>.</dd>
2855:
2856: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2857: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2858: token. Append the lowercase version of the <a href="#current-input-character">current input
2859: character</a> (add 0x0020 to the character's code point) to the
2860: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
2861: escape start state</a>.</dd>
2862:
2863: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2864: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2865: token. Append the <a href="#current-input-character">current input character</a> to the
2866: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
2867: escape start state</a>.</dd>
2868:
2869: <dt>Anything else</dt>
2870: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2871: <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2872:
1.618 mike 2873: </dl><h5 id="script-data-double-escaped-state"><span class="secno">9.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 2874:
2875: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2876:
2877: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2878: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2879: <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
2880:
2881: <dt>U+003C LESS-THAN SIGN (<)</dt>
2882: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2883: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2884: state</a>.</p></dd>
2885:
2886: <dt>EOF</dt>
2887: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2888: <a href="#data-state">data state</a>.</dd>
2889:
2890: <dt>Anything else</dt>
2891: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2892: token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
2893: state</a>.</dd>
2894:
1.618 mike 2895: </dl><h5 id="script-data-double-escaped-dash-state"><span class="secno">9.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 2896:
2897: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2898:
2899: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2900: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2901: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
2902:
2903: <dt>U+003C LESS-THAN SIGN (<)</dt>
2904: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2905: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2906: state</a>.</p></dd>
2907:
2908: <dt>EOF</dt>
2909: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2910: <a href="#data-state">data state</a>.</dd>
2911:
2912: <dt>Anything else</dt>
2913: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2914: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
2915: state</a>.</dd>
2916:
1.618 mike 2917: </dl><h5 id="script-data-double-escaped-dash-dash-state"><span class="secno">9.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 2918:
2919: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2920:
2921: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2922: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
2923: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
2924:
2925: <dt>U+003C LESS-THAN SIGN (<)</dt>
2926: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2927: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2928: state</a>.</p></dd>
2929:
2930: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2931: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
2932: <a href="#script-data-state">script data state</a>.</dd>
2933:
2934: <dt>EOF</dt>
2935: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2936: <a href="#data-state">data state</a>.</dd>
2937:
2938: <dt>Anything else</dt>
2939: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2940: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
2941: state</a>.</dd>
2942:
1.618 mike 2943: </dl><h5 id="script-data-double-escaped-less-than-sign-state"><span class="secno">9.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 2944:
2945: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2946:
2947: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2948: <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
2949: buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
2950: double escape end state</a>.</dd>
2951:
2952: <dt>Anything else</dt>
2953: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2954: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
2955:
1.618 mike 2956: </dl><h5 id="script-data-double-escape-end-state"><span class="secno">9.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 2957:
2958: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2959:
2960: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2961: <dt>U+000A LINE FEED (LF)</dt>
2962: <dt>U+000C FORM FEED (FF)</dt>
2963: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2964: <dt>U+0020 SPACE</dt>
2965: <dt>U+002F SOLIDUS (/)</dt>
2966: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2967: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2968: 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
2969: escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
2970: double escaped state</a>.</dd>
2971:
2972: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2973: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2974: token. Append the lowercase version of the <a href="#current-input-character">current input
2975: character</a> (add 0x0020 to the character's code point) to the
2976: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
2977: escape end state</a>.</dd>
2978:
2979: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2980: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2981: token. Append the <a href="#current-input-character">current input character</a> to the
2982: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
2983: escape end state</a>.</dd>
2984:
2985: <dt>Anything else</dt>
2986: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2987: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1 mike 2988:
1.618 mike 2989: </dl><h5 id="before-attribute-name-state"><span class="secno">9.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 2990:
2991: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2992:
2993: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2994: <dt>U+000A LINE FEED (LF)</dt>
2995: <dt>U+000C FORM FEED (FF)</dt>
2996: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2997: <dt>U+0020 SPACE</dt>
2998: <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
2999:
3000: <dt>U+002F SOLIDUS (/)</dt>
3001: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3002:
3003: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3004: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3005: state</a>.</dd>
3006:
3007: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3008: <dd>Start a new attribute in the current tag token. Set that
3009: attribute's name to the lowercase version of the <a href="#current-input-character">current input
3010: character</a> (add 0x0020 to the character's code point), and its
3011: value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
3012: state</a>.</dd>
3013:
3014: <dt>U+0022 QUOTATION MARK (")</dt>
3015: <dt>U+0027 APOSTROPHE (')</dt>
3016: <dt>U+003C LESS-THAN SIGN (<)</dt>
3017: <dt>U+003D EQUALS SIGN (=)</dt>
3018: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3019: entry below.</dd>
3020:
3021: <dt>EOF</dt>
3022: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3023: <a href="#data-state">data state</a>.</dd>
3024:
3025: <dt>Anything else</dt>
3026: <dd>Start a new attribute in the current tag token. Set that
3027: attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
3028: the empty string. Switch to the <a href="#attribute-name-state">attribute name
3029: state</a>.</dd>
3030:
1.618 mike 3031: </dl><h5 id="attribute-name-state"><span class="secno">9.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 3032:
3033: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3034:
3035: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3036: <dt>U+000A LINE FEED (LF)</dt>
3037: <dt>U+000C FORM FEED (FF)</dt>
3038: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3039: <dt>U+0020 SPACE</dt>
3040: <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3041:
3042: <dt>U+002F SOLIDUS (/)</dt>
3043: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3044:
3045: <dt>U+003D EQUALS SIGN (=)</dt>
3046: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3047:
3048: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3049: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3050: state</a>.</dd>
3051:
3052: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3053: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3054: character</a> (add 0x0020 to the character's code point) to the
3055: current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1 mike 3056: state</a>.</dd>
3057:
3058: <dt>U+0022 QUOTATION MARK (")</dt>
3059: <dt>U+0027 APOSTROPHE (')</dt>
3060: <dt>U+003C LESS-THAN SIGN (<)</dt>
3061: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3062: entry below.</dd>
3063:
3064: <dt>EOF</dt>
3065: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3066: <a href="#data-state">data state</a>.</dd>
3067:
3068: <dt>Anything else</dt>
1.541 mike 3069: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3070: attribute's name. Stay in the <a href="#attribute-name-state">attribute name
3071: state</a>.</dd>
1.1 mike 3072:
3073: </dl><p>When the user agent leaves the attribute name state (and before
3074: emitting the tag token, if appropriate), the complete attribute's
3075: name must be compared to the other attributes on the same token;
3076: if there is already an attribute on the token with the exact same
3077: name, then this is a <a href="#parse-error">parse error</a> and the new
3078: attribute must be dropped, along with the value that gets
3079: associated with it (if any).</p>
3080:
3081:
1.618 mike 3082: <h5 id="after-attribute-name-state"><span class="secno">9.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 3083:
3084: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3085:
3086: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3087: <dt>U+000A LINE FEED (LF)</dt>
3088: <dt>U+000C FORM FEED (FF)</dt>
3089: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3090: <dt>U+0020 SPACE</dt>
3091: <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3092:
3093: <dt>U+002F SOLIDUS (/)</dt>
3094: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3095:
3096: <dt>U+003D EQUALS SIGN (=)</dt>
3097: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3098:
3099: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3100: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3101: state</a>.</dd>
3102:
3103: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3104: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3105: attribute's name to the lowercase version of the <a href="#current-input-character">current
3106: input character</a> (add 0x0020 to the character's code point),
3107: and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
3108: name state</a>.</dd>
1.1 mike 3109:
3110: <dt>U+0022 QUOTATION MARK (")</dt>
3111: <dt>U+0027 APOSTROPHE (')</dt>
3112: <dt>U+003C LESS-THAN SIGN (<)</dt>
3113: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3114: entry below.</dd>
3115:
3116: <dt>EOF</dt>
3117: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3118: <a href="#data-state">data state</a>.</dd>
3119:
3120: <dt>Anything else</dt>
3121: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3122: attribute's name to the <a href="#current-input-character">current input character</a>, and
3123: its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1 mike 3124: state</a>.</dd>
3125:
1.618 mike 3126: </dl><h5 id="before-attribute-value-state"><span class="secno">9.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 3127:
3128: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3129:
3130: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3131: <dt>U+000A LINE FEED (LF)</dt>
3132: <dt>U+000C FORM FEED (FF)</dt>
3133: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3134: <dt>U+0020 SPACE</dt>
3135: <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3136:
3137: <dt>U+0022 QUOTATION MARK (")</dt>
3138: <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
3139:
3140: <dt>U+0026 AMPERSAND (&)</dt>
3141: <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541 mike 3142: and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1 mike 3143:
3144: <dt>U+0027 APOSTROPHE (')</dt>
3145: <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
3146:
3147: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3148: <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
3149: the <a href="#data-state">data state</a>.</dd>
3150:
3151: <dt>U+003C LESS-THAN SIGN (<)</dt>
3152: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3153: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3154: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3155: entry below.</dd>
3156:
3157: <dt>EOF</dt>
3158: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3159: <a href="#data-state">data state</a>.</dd>
3160:
3161: <dt>Anything else</dt>
3162: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3163: attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
3164: state</a>.</dd>
3165:
1.618 mike 3166: </dl><h5 id="attribute-value-double-quoted-state"><span class="secno">9.2.4.38 </span><dfn>Attribute value (double-quoted) state</dfn></h5>
1.1 mike 3167:
3168: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3169:
3170: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3171: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3172: state</a>.</dd>
3173:
3174: <dt>U+0026 AMPERSAND (&)</dt>
3175: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3176: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3177: being U+0022 QUOTATION MARK (").</dd>
3178:
3179: <dt>EOF</dt>
3180: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3181: <a href="#data-state">data state</a>.</dd>
3182:
3183: <dt>Anything else</dt>
1.541 mike 3184: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3185: attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
3186: (double-quoted) state</a>.</dd>
1.1 mike 3187:
1.618 mike 3188: </dl><h5 id="attribute-value-single-quoted-state"><span class="secno">9.2.4.39 </span><dfn>Attribute value (single-quoted) state</dfn></h5>
1.1 mike 3189:
3190: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3191:
3192: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3193: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3194: state</a>.</dd>
3195:
3196: <dt>U+0026 AMPERSAND (&)</dt>
3197: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3198: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3199: being U+0027 APOSTROPHE (').</dd>
3200:
3201: <dt>EOF</dt>
3202: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3203: <a href="#data-state">data state</a>.</dd>
3204:
3205: <dt>Anything else</dt>
1.541 mike 3206: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3207: attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
3208: (single-quoted) state</a>.</dd>
1.1 mike 3209:
1.618 mike 3210: </dl><h5 id="attribute-value-unquoted-state"><span class="secno">9.2.4.40 </span><dfn>Attribute value (unquoted) state</dfn></h5>
1.1 mike 3211:
3212: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3213:
3214: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3215: <dt>U+000A LINE FEED (LF)</dt>
3216: <dt>U+000C FORM FEED (FF)</dt>
3217: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3218: <dt>U+0020 SPACE</dt>
3219: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3220:
3221: <dt>U+0026 AMPERSAND (&)</dt>
3222: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299 mike 3223: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3224: being U+003E GREATER-THAN SIGN (>).</dd>
1.1 mike 3225:
3226: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3227: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3228: state</a>.</dd>
3229:
3230: <dt>U+0022 QUOTATION MARK (")</dt>
3231: <dt>U+0027 APOSTROPHE (')</dt>
3232: <dt>U+003C LESS-THAN SIGN (<)</dt>
3233: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3234: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3235: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3236: entry below.</dd>
3237:
3238: <dt>EOF</dt>
3239: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3240: <a href="#data-state">data state</a>.</dd>
3241:
3242: <dt>Anything else</dt>
1.541 mike 3243: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3244: attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1 mike 3245: state</a>.</dd>
3246:
1.618 mike 3247: </dl><h5 id="character-reference-in-attribute-value-state"><span class="secno">9.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 3248:
3249: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
3250:
3251: <p>If nothing is returned, append a U+0026 AMPERSAND character to
3252: the current attribute's value.</p>
3253:
3254: <p>Otherwise, append the returned character token to the current
3255: attribute's value.</p>
3256:
3257: <p>Finally, switch back to the attribute value state that you were
3258: in when were switched into this state.</p>
3259:
3260:
1.618 mike 3261: <h5 id="after-attribute-value-quoted-state"><span class="secno">9.2.4.42 </span><dfn>After attribute value (quoted) state</dfn></h5>
1.1 mike 3262:
3263: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3264:
3265: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3266: <dt>U+000A LINE FEED (LF)</dt>
3267: <dt>U+000C FORM FEED (FF)</dt>
3268: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3269: <dt>U+0020 SPACE</dt>
3270: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3271:
3272: <dt>U+002F SOLIDUS (/)</dt>
3273: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3274:
3275: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3276: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3277: state</a>.</dd>
3278:
3279: <dt>EOF</dt>
3280: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3281: <a href="#data-state">data state</a>.</dd>
3282:
3283: <dt>Anything else</dt>
3284: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3285: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3286:
1.618 mike 3287: </dl><h5 id="self-closing-start-tag-state"><span class="secno">9.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 3288:
3289: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3290:
3291: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3292: <dd>Set the <i>self-closing flag</i> of the current tag
3293: token. Emit the current tag token. Switch to the <a href="#data-state">data
3294: state</a>.</dd>
3295:
3296: <dt>EOF</dt>
3297: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3298: <a href="#data-state">data state</a>.</dd>
3299:
3300: <dt>Anything else</dt>
3301: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3302: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3303:
1.618 mike 3304: </dl><h5 id="bogus-comment-state"><span class="secno">9.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 3305:
3306: <p>Consume every character up to and including the first U+003E
3307: GREATER-THAN SIGN character (>) or the end of the file (EOF),
3308: whichever comes first. Emit a comment token whose data is the
3309: concatenation of all the characters starting from and including
3310: the character that caused the state machine to switch into the
3311: bogus comment state, up to and including the character immediately
3312: before the last consumed character (i.e. up to the character just
3313: before the U+003E or EOF character). (If the comment was started
3314: by the end of the file (EOF), the token is empty.)</p>
3315:
3316: <p>Switch to the <a href="#data-state">data state</a>.</p>
3317:
3318: <p>If the end of the file was reached, reconsume the EOF
3319: character.</p>
3320:
3321:
1.618 mike 3322: <h5 id="markup-declaration-open-state"><span class="secno">9.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 3323:
1.588 mike 3324: <p>If the next two characters are both U+002D HYPHEN-MINUS
3325: characters (-), consume those two characters, create a comment token
1.1 mike 3326: whose data is the empty string, and switch to the <a href="#comment-start-state">comment
3327: start state</a>.</p>
3328:
3329: <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3330: case-insensitive</a> match for the word "DOCTYPE", then consume
3331: those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
3332:
3333: <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
3334: content</a>" and the <a href="#current-node">current node</a> is not an element
3335: in the <a href="#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585 mike 3336: an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
3337: five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
3338: character before and after), then consume those characters and
3339: switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1 mike 3340:
3341: <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
3342: <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
3343: consumed, if any, is the first character that will be in the
3344: comment.</p>
3345:
3346:
1.618 mike 3347: <h5 id="comment-start-state"><span class="secno">9.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 3348:
3349: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3350:
3351: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3352: <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
3353:
3354: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3355: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
3356: <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
3357: -->
3358:
3359: <dt>EOF</dt>
3360: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3361: the EOF character in the <a href="#data-state">data state</a>.</dd>
3362:
3363: <dt>Anything else</dt>
1.541 mike 3364: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3365: token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3366:
1.618 mike 3367: </dl><h5 id="comment-start-dash-state"><span class="secno">9.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 3368:
3369: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3370:
3371: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3372: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3373:
3374: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3375: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
3376: the <a href="#data-state">data state</a>.</dd>
3377:
3378: <dt>EOF</dt>
3379: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3380: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3381: in comment end state -->
3382:
3383: <dt>Anything else</dt>
1.541 mike 3384: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3385: <a href="#current-input-character">current input character</a> to the comment token's
3386: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3387:
1.618 mike 3388: </dl><h5 id="comment-state"><span class="secno">9.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 3389:
3390: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3391:
3392: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3393: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
3394:
3395: <dt>EOF</dt>
3396: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3397: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3398: in comment end state -->
3399:
3400: <dt>Anything else</dt>
1.541 mike 3401: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3402: token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3403:
1.618 mike 3404: </dl><h5 id="comment-end-dash-state"><span class="secno">9.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 3405:
3406: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3407:
3408: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3409: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3410:
3411: <dt>EOF</dt>
3412: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3413: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3414: in comment end state -->
3415:
3416: <dt>Anything else</dt>
1.541 mike 3417: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3418: <a href="#current-input-character">current input character</a> to the comment token's
3419: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3420:
1.618 mike 3421: </dl><h5 id="comment-end-state"><span class="secno">9.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 3422:
3423: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3424:
3425: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3426: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3427: state</a>.</dd>
3428:
3429: <dt>U+0009 CHARACTER TABULATION</dt>
3430: <dt>U+000A LINE FEED (LF)</dt>
3431: <dt>U+000C FORM FEED (FF)</dt>
3432: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3433: <dt>U+0020 SPACE</dt>
1.588 mike 3434: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3435: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3436: comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
3437: state</a>.</dd>
1.1 mike 3438:
3439: <dt>U+0021 EXCLAMATION MARK (!)</dt>
3440: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
3441: state</a>.</dd>
3442:
1.333 mike 3443: <dt>U+002D HYPHEN-MINUS (-)</dt>
3444: <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464 mike 3445: character (-) to the comment token's data. Stay in the
1.333 mike 3446: <a href="#comment-end-state">comment end state</a>.</dd>
3447:
1.1 mike 3448: <dt>EOF</dt>
3449: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3450: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
3451: security reasons: otherwise, hostile user could put a <script> in
3452: a comment e.g. in a blog comment and then DOS the server so that
3453: the end tag isn't read, and then the commented <script> tag would
3454: be treated as live code -->
3455:
3456: <dt>Anything else</dt>
1.588 mike 3457: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3458: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3459: comment token's data. Switch to the <a href="#comment-state">comment
3460: state</a>.</dd>
1.1 mike 3461:
1.618 mike 3462: </dl><h5 id="comment-end-bang-state"><span class="secno">9.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 3463:
3464: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3465:
1.333 mike 3466: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588 mike 3467: <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464 mike 3468: EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1 mike 3469: to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3470:
1.333 mike 3471: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3472: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3473: state</a>.</dd>
3474:
1.1 mike 3475: <dt>EOF</dt>
3476: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3477: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3478: comment in comment end state -->
3479:
3480: <dt>Anything else</dt>
1.588 mike 3481: <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541 mike 3482: EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
3483: character</a> to the comment token's data. Switch to the
3484: <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3485:
1.618 mike 3486: </dl><h5 id="comment-end-space-state"><span class="secno">9.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 3487:
3488: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3489:
1.333 mike 3490: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1 mike 3491: <dt>U+000A LINE FEED (LF)</dt>
3492: <dt>U+000C FORM FEED (FF)</dt>
3493: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3494: <dt>U+0020 SPACE</dt>
1.541 mike 3495: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1 mike 3496: the <a href="#comment-end-space-state">comment end space state</a>.</dd>
3497:
1.333 mike 3498: <dt>U+002D HYPHEN-MINUS (-)</dt>
3499: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3500:
3501: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3502: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3503: state</a>.</dd>
3504:
1.1 mike 3505: <dt>EOF</dt>
3506: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3507: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3508: comment in comment end state -->
3509:
3510: <dt>Anything else</dt>
1.541 mike 3511: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1 mike 3512: to the <a href="#comment-state">comment state</a>.</dd>
3513:
1.618 mike 3514: </dl><h5 id="doctype-state"><span class="secno">9.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 3515:
3516: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3517:
3518: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3519: <dt>U+000A LINE FEED (LF)</dt>
3520: <dt>U+000C FORM FEED (FF)</dt>
3521: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3522: <dt>U+0020 SPACE</dt>
3523: <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3524:
3525: <dt>EOF</dt>
3526: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3527: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3528: the EOF character in the <a href="#data-state">data state</a>.</dd>
3529:
3530: <dt>Anything else</dt>
1.608 mike 3531: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
3532: <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1 mike 3533:
1.618 mike 3534: </dl><h5 id="before-doctype-name-state"><span class="secno">9.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 3535:
3536: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3537:
3538: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3539: <dt>U+000A LINE FEED (LF)</dt>
3540: <dt>U+000C FORM FEED (FF)</dt>
3541: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3542: <dt>U+0020 SPACE</dt>
3543: <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3544:
3545: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3546: <dd>Create a new DOCTYPE token. Set the token's name to the
1.541 mike 3547: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1 mike 3548: character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
3549: state</a>.</dd>
3550:
1.333 mike 3551: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3552: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3553: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
3554: the <a href="#data-state">data state</a>.</dd>
3555:
1.1 mike 3556: <dt>EOF</dt>
3557: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3558: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3559: the EOF character in the <a href="#data-state">data state</a>.</dd>
3560:
3561: <dt>Anything else</dt>
3562: <dd>Create a new DOCTYPE token. Set the token's name to the
3563: <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
3564: state</a>.</dd>
3565:
1.618 mike 3566: </dl><h5 id="doctype-name-state"><span class="secno">9.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 3567:
3568: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3569:
3570: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3571: <dt>U+000A LINE FEED (LF)</dt>
3572: <dt>U+000C FORM FEED (FF)</dt>
3573: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3574: <dt>U+0020 SPACE</dt>
3575: <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3576:
3577: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3578: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3579: state</a>.</dd>
3580:
3581: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3582: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3583: character</a> (add 0x0020 to the character's code point) to the
3584: current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3585: state</a>.</dd>
1.1 mike 3586:
3587: <dt>EOF</dt>
3588: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3589: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3590: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3591:
3592: <dt>Anything else</dt>
1.541 mike 3593: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3594: DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3595: state</a>.</dd>
1.1 mike 3596:
1.618 mike 3597: </dl><h5 id="after-doctype-name-state"><span class="secno">9.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 3598:
3599: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3600:
3601: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3602: <dt>U+000A LINE FEED (LF)</dt>
3603: <dt>U+000C FORM FEED (FF)</dt>
3604: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3605: <dt>U+0020 SPACE</dt>
3606: <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3607:
3608: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3609: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3610: state</a>.</dd>
3611:
3612: <dt>EOF</dt>
3613: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3614: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3615: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3616:
3617: <dt>Anything else</dt>
3618: <dd>
3619:
3620: <p>If the six characters starting from the <a href="#current-input-character">current input
3621: character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
3622: for the word "PUBLIC", then consume those characters and switch to
1.444 mike 3623: the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1 mike 3624:
3625: <p>Otherwise, if the six characters starting from the
3626: <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3627: case-insensitive</a> match for the word "SYSTEM", then consume
1.444 mike 3628: those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
3629: keyword state</a>.</p>
1.1 mike 3630:
3631: <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
3632: DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
3633: the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
3634:
3635: </dd>
3636:
1.618 mike 3637: </dl><h5 id="after-doctype-public-keyword-state"><span class="secno">9.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 3638:
3639: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3640:
3641: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3642: <dt>U+000A LINE FEED (LF)</dt>
3643: <dt>U+000C FORM FEED (FF)</dt>
3644: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3645: <dt>U+0020 SPACE</dt>
3646: <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
3647: state</a>.</dd>
3648:
1.620 mike 3649: <dt>U+0022 QUOTATION MARK (")</dt>
3650: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3651: identifier to the empty string (not missing), then switch to the
3652: <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
3653:
3654: <dt>U+0027 APOSTROPHE (')</dt>
3655: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3656: identifier to the empty string (not missing), then switch to the
3657: <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
3658:
3659: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3660: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3661: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3662: token. Switch to the <a href="#data-state">data state</a>.</dd>
3663:
1.444 mike 3664: <dt>EOF</dt>
3665: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3666: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3667: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3668:
3669: <dt>Anything else</dt>
1.620 mike 3670: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3671: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3672: DOCTYPE state</a>.</dd>
1.444 mike 3673:
1.618 mike 3674: </dl><h5 id="before-doctype-public-identifier-state"><span class="secno">9.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 3675:
3676: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3677:
3678: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3679: <dt>U+000A LINE FEED (LF)</dt>
3680: <dt>U+000C FORM FEED (FF)</dt>
3681: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3682: <dt>U+0020 SPACE</dt>
3683: <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
3684:
3685: <dt>U+0022 QUOTATION MARK (")</dt>
3686: <dd>Set the DOCTYPE token's public identifier to the empty string
3687: (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
3688: (double-quoted) state</a>.</dd>
3689:
3690: <dt>U+0027 APOSTROPHE (')</dt>
3691: <dd>Set the DOCTYPE token's public identifier to the empty string
3692: (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
3693: (single-quoted) state</a>.</dd>
3694:
3695: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3696: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3697: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3698: token. Switch to the <a href="#data-state">data state</a>.</dd>
3699:
3700: <dt>EOF</dt>
3701: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3702: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3703: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3704:
3705: <dt>Anything else</dt>
3706: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3707: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3708: DOCTYPE state</a>.</dd>
3709:
1.618 mike 3710: </dl><h5 id="doctype-public-identifier-double-quoted-state"><span class="secno">9.2.4.59 </span><dfn>DOCTYPE public identifier (double-quoted) state</dfn></h5>
1.1 mike 3711:
3712: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3713:
3714: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3715: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3716:
3717: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3718: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3719: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3720: token. Switch to the <a href="#data-state">data state</a>.</dd>
3721:
3722: <dt>EOF</dt>
3723: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3724: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3725: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3726:
3727: <dt>Anything else</dt>
3728: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3729: token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
3730: identifier (double-quoted) state</a>.</dd>
3731:
1.618 mike 3732: </dl><h5 id="doctype-public-identifier-single-quoted-state"><span class="secno">9.2.4.60 </span><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5>
1.1 mike 3733:
3734: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3735:
3736: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3737: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3738:
3739: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3740: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3741: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3742: token. Switch to the <a href="#data-state">data state</a>.</dd>
3743:
3744: <dt>EOF</dt>
3745: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3746: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3747: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3748:
3749: <dt>Anything else</dt>
3750: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3751: token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
3752: identifier (single-quoted) state</a>.</dd>
3753:
1.618 mike 3754: </dl><h5 id="after-doctype-public-identifier-state"><span class="secno">9.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 3755:
3756: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3757:
3758: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3759: <dt>U+000A LINE FEED (LF)</dt>
3760: <dt>U+000C FORM FEED (FF)</dt>
3761: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3762: <dt>U+0020 SPACE</dt>
1.541 mike 3763: <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
3764: identifiers state</a>.</dd>
1.444 mike 3765:
3766: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3767: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3768: state</a>.</dd>
3769:
3770: <dt>U+0022 QUOTATION MARK (")</dt>
3771: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3772: identifier to the empty string (not missing), then switch to the
3773: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3774:
3775: <dt>U+0027 APOSTROPHE (')</dt>
3776: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3777: identifier to the empty string (not missing), then switch to the
3778: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3779:
3780: <dt>EOF</dt>
3781: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3782: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3783: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3784:
3785: <dt>Anything else</dt>
3786: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3787: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3788: DOCTYPE state</a>.</dd>
3789:
1.618 mike 3790: </dl><h5 id="between-doctype-public-and-system-identifiers-state"><span class="secno">9.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 3791:
3792: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3793:
3794: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3795: <dt>U+000A LINE FEED (LF)</dt>
3796: <dt>U+000C FORM FEED (FF)</dt>
3797: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3798: <dt>U+0020 SPACE</dt>
1.541 mike 3799: <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
3800: state</a>.</dd>
1.444 mike 3801:
3802: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3803: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3804: state</a>.</dd>
1.1 mike 3805:
3806: <dt>U+0022 QUOTATION MARK (")</dt>
3807: <dd>Set the DOCTYPE token's system identifier to the empty string
3808: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3809: (double-quoted) state</a>.</dd>
3810:
3811: <dt>U+0027 APOSTROPHE (')</dt>
3812: <dd>Set the DOCTYPE token's system identifier to the empty string
3813: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3814: (single-quoted) state</a>.</dd>
3815:
3816: <dt>EOF</dt>
3817: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3818: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3819: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3820:
3821: <dt>Anything else</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>. Switch to the <a href="#bogus-doctype-state">bogus
3824: DOCTYPE state</a>.</dd>
3825:
1.618 mike 3826: </dl><h5 id="after-doctype-system-keyword-state"><span class="secno">9.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 3827:
3828: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3829:
3830: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3831: <dt>U+000A LINE FEED (LF)</dt>
3832: <dt>U+000C FORM FEED (FF)</dt>
3833: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3834: <dt>U+0020 SPACE</dt>
3835: <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
3836: state</a>.</dd>
3837:
1.620 mike 3838: <dt>U+0022 QUOTATION MARK (")</dt>
3839: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3840: identifier to the empty string (not missing), then switch to the
3841: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3842:
3843: <dt>U+0027 APOSTROPHE (')</dt>
3844: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3845: identifier to the empty string (not missing), then switch to the
3846: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3847:
3848: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3849: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3850: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3851: token. Switch to the <a href="#data-state">data state</a>.</dd>
3852:
1.444 mike 3853: <dt>EOF</dt>
3854: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3855: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3856: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3857:
3858: <dt>Anything else</dt>
1.620 mike 3859: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3860: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3861: DOCTYPE state</a>.</dd>
1.444 mike 3862:
1.618 mike 3863: </dl><h5 id="before-doctype-system-identifier-state"><span class="secno">9.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 3864:
3865: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3866:
3867: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3868: <dt>U+000A LINE FEED (LF)</dt>
3869: <dt>U+000C FORM FEED (FF)</dt>
3870: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3871: <dt>U+0020 SPACE</dt>
3872: <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
3873:
3874: <dt>U+0022 QUOTATION MARK (")</dt>
3875: <dd>Set the DOCTYPE token's system identifier to the empty string
3876: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3877: (double-quoted) state</a>.</dd>
3878:
3879: <dt>U+0027 APOSTROPHE (')</dt>
3880: <dd>Set the DOCTYPE token's system identifier to the empty string
3881: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3882: (single-quoted) state</a>.</dd>
3883:
3884: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3885: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3886: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3887: token. Switch to the <a href="#data-state">data state</a>.</dd>
3888:
3889: <dt>EOF</dt>
3890: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3891: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3892: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3893:
3894: <dt>Anything else</dt>
3895: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3896: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3897: DOCTYPE state</a>.</dd>
3898:
1.618 mike 3899: </dl><h5 id="doctype-system-identifier-double-quoted-state"><span class="secno">9.2.4.65 </span><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5>
1.1 mike 3900:
3901: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3902:
3903: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541 mike 3904: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
3905: state</a>.</dd>
1.1 mike 3906:
3907: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3908: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3909: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3910: token. Switch to the <a href="#data-state">data state</a>.</dd>
3911:
3912: <dt>EOF</dt>
3913: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3914: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3915: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3916:
3917: <dt>Anything else</dt>
1.541 mike 3918: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3919: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1 mike 3920: identifier (double-quoted) state</a>.</dd>
3921:
1.618 mike 3922: </dl><h5 id="doctype-system-identifier-single-quoted-state"><span class="secno">9.2.4.66 </span><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5>
1.1 mike 3923:
3924: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3925:
3926: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541 mike 3927: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
3928: state</a>.</dd>
1.1 mike 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:
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.541 mike 3941: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3942: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1 mike 3943: identifier (single-quoted) state</a>.</dd>
3944:
1.618 mike 3945: </dl><h5 id="after-doctype-system-identifier-state"><span class="secno">9.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 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>
1.541 mike 3954: <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
3955: state</a>.</dd>
1.1 mike 3956:
3957: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3958: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3959: state</a>.</dd>
3960:
3961: <dt>EOF</dt>
3962: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3963: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3964: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3965:
3966: <dt>Anything else</dt>
3967: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
3968: state</a>. (This does <em>not</em> set the DOCTYPE token's
3969: <i>force-quirks flag</i> to <i>on</i>.)</dd>
3970:
1.618 mike 3971: </dl><h5 id="bogus-doctype-state"><span class="secno">9.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 3972:
3973: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3974:
3975: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3976: <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
3977: state</a>.</dd>
3978:
3979: <dt>EOF</dt>
3980: <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
3981: <a href="#data-state">data state</a>.</dd>
3982:
3983: <dt>Anything else</dt>
3984: <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
3985:
1.618 mike 3986: </dl><h5 id="cdata-section-state"><span class="secno">9.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 3987:
3988: <p>Consume every character up to the next occurrence of the three
3989: character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
3990: BRACKET U+003E GREATER-THAN SIGN (<code title="">]]></code>), or the
3991: end of the file (EOF), whichever comes first. Emit a series of
3992: character tokens consisting of all the characters consumed except
3993: the matching three character sequence at the end (if one was found
3994: before the end of the file).</p>
3995:
3996: <p>Switch to the <a href="#data-state">data state</a>.</p>
3997:
3998: <p>If the end of the file was reached, reconsume the EOF
3999: character.</p>
4000:
4001:
4002:
1.618 mike 4003: <h5 id="tokenizing-character-references"><span class="secno">9.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 4004:
4005: <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
4006: reference</dfn>. This definition is used when parsing character
1.299 mike 4007: references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1 mike 4008: text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
4009: state">in attributes</a>.</p>
4010:
4011: <p>The behavior depends on the identity of the next character (the
4012: one immediately after the U+0026 AMPERSAND character):</p>
4013:
4014: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4015: <dt>U+000A LINE FEED (LF)</dt>
4016: <dt>U+000C FORM FEED (FF)</dt>
4017: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4018: <dt>U+0020 SPACE</dt>
4019: <dt>U+003C LESS-THAN SIGN</dt>
4020: <dt>U+0026 AMPERSAND</dt>
4021: <dt>EOF</dt>
4022: <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
4023:
4024: <dd>Not a character reference. No characters are consumed, and
4025: nothing is returned. (This is not an error, either.)</dd>
4026:
4027:
4028: <dt>U+0023 NUMBER SIGN (#)</dt>
4029:
4030: <dd>
4031:
4032: <p>Consume the U+0023 NUMBER SIGN.</p>
4033:
4034: <p>The behavior further depends on the character after the U+0023
4035: NUMBER SIGN:</p>
4036:
4037: <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
4038: <dt>U+0058 LATIN CAPITAL LETTER X</dt>
4039:
4040: <dd>
4041:
4042: <p>Consume the X.</p>
4043:
4044: <p>Follow the steps below, but using the range of characters
1.464 mike 4045: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
4046: SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
4047: CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
4048: words, 0-9, A-F, a-f).</p>
1.1 mike 4049:
4050: <p>When it comes to interpreting the number, interpret it as a
4051: hexadecimal number.</p>
4052:
4053: </dd>
4054:
4055:
4056: <dt>Anything else</dt>
4057:
4058: <dd>
4059:
4060: <p>Follow the steps below, but using the range of characters
1.464 mike 4061: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1 mike 4062:
4063: <p>When it comes to interpreting the number, interpret it as a
4064: decimal number.</p>
4065:
4066: </dd>
4067:
4068: </dl><p>Consume as many characters as match the range of characters
4069: given above.</p>
4070:
4071: <p>If no characters match the range, then don't consume any
4072: characters (and unconsume the U+0023 NUMBER SIGN character and, if
4073: appropriate, the X character). This is a <a href="#parse-error">parse
4074: error</a>; nothing is returned.</p>
4075:
4076: <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
4077: that too. If it isn't, there is a <a href="#parse-error">parse
4078: error</a>.</p>
4079:
4080: <p>If one or more characters match the range, then take them all
4081: and interpret the string of characters as a number (either
4082: hexadecimal or decimal as appropriate).</p>
4083:
4084: <p>If that number is one of the numbers in the first column of the
4085: following table, then this is a <a href="#parse-error">parse error</a>. Find the
4086: row with that number in the first column, and return a character
4087: token for the Unicode character given in the second column of that
4088: row.</p>
4089:
4090: <table><thead><tr><th>Number </th><th colspan="2">Unicode character
4091: </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
4092: </td></tr><tr><td>0x0D </td><td>U+000A </td><td>LINE FEED (LF)
1.464 mike 4093: </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (€)
1.1 mike 4094: </td></tr><tr><td>0x81 </td><td>U+0081 </td><td><control>
1.464 mike 4095: </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (‚)
4096: </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (ƒ)
4097: </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK („)
4098: </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (…)
4099: </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (†)
4100: </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (‡)
4101: </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
4102: </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (‰)
4103: </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (Š)
4104: </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
4105: </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (Œ)
1.1 mike 4106: </td></tr><tr><td>0x8D </td><td>U+008D </td><td><control>
1.464 mike 4107: </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
1.1 mike 4108: </td></tr><tr><td>0x8F </td><td>U+008F </td><td><control>
4109: </td></tr><tr><td>0x90 </td><td>U+0090 </td><td><control>
1.464 mike 4110: </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (‘)
4111: </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (’)
4112: </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (“)
4113: </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (”)
4114: </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (•)
4115: </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (–)
4116: </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (—)
4117: </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (˜)
4118: </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (™)
4119: </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (š)
4120: </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
4121: </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (œ)
1.1 mike 4122: </td></tr><tr><td>0x9D </td><td>U+009D </td><td><control>
1.464 mike 4123: </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (ž)
4124: </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
1.315 mike 4125: </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
4126: surrogates not allowed; see the comment in the "preprocessing the
4127: input stream" section for details --> or is greater than 0x10FFFF,
4128: then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
4129: REPLACEMENT CHARACTER.</p>
1.18 mike 4130:
4131: <p>Otherwise, return a character token for the Unicode character
1.1 mike 4132: whose code point is that number.
4133:
4134: <!-- this is the same as the equivalent list in the input stream
4135: section -->
4136: If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
4137: allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
4138: allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315 mike 4139: 0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
4140: 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
4141: 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
4142: 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
4143: 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
4144: 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
4145: 0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
4146: error</a>.</p>
1.1 mike 4147:
4148: </dd>
4149:
4150:
4151: <dt>Anything else</dt>
4152:
4153: <dd>
4154:
4155: <p>Consume the maximum number of characters possible, with the
4156: consumed characters matching one of the identifiers in the first
4157: column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
4158: <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
4159:
4160: <p>If no match can be made, then this is a <a href="#parse-error">parse
4161: error</a>. No characters are consumed, and nothing is
4162: returned.</p>
4163:
1.588 mike 4164: <p>If the last character matched is not a U+003B SEMICOLON
4165: character (;), there is a <a href="#parse-error">parse error</a>.</p>
1.1 mike 4166:
4167: <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
4168: attribute</a>, and the last character matched is not a U+003B
1.588 mike 4169: SEMICOLON character (;), and the next character is in the range
4170: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
4171: CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN
4172: SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for
4173: historical reasons, all the characters that were matched after the
4174: U+0026 AMPERSAND character (&) must be unconsumed, and nothing
4175: is returned.</p>
1.1 mike 4176:
4177: <p>Otherwise, return a character token for the character
4178: corresponding to the character reference name (as given by the
4179: second column of the <a href="named-character-references.html#named-character-references">named character references</a>
4180: table).</p>
4181:
4182: <div class="example">
4183:
4184: <p>If the markup contains <code title="">I'm &notit; I tell
4185: you</code>, the character reference is parsed as "not", as in,
4186: <code title="">I'm ¬it; I tell you</code>. But if the markup
4187: was <code title="">I'm &notin; I tell you</code>, the
4188: character reference would be parsed as "notin;", resulting in
4189: <code title="">I'm ∉ I tell you</code>.</p>
4190:
4191: </div>
4192:
4193: </dd>
4194:
1.266 mike 4195: </dl></div><div class="impl">
4196:
1.363 mike 4197: <!-- v2: One thing that this doesn't define is handling deeply
4198: nested documents. There are compatibility requirements around that:
4199: you can't throw away the elements altogether, consider Tux made only
4200: with opening <font> elements, one per character. Seems that the best
4201: thing to do is to close some formatting elements from the middle of
4202: the stack when you hit a limit, or something. -->
4203:
1.614 mike 4204: <h4 id="tree-construction"><span class="secno">9.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 4205:
4206: <p>The input to the tree construction stage is a sequence of tokens
4207: from the <a href="#tokenization">tokenization</a> stage. The tree construction
4208: stage is associated with a DOM <code>Document</code> object when a
4209: parser is created. The "output" of this stage consists of
4210: dynamically modifying or extending that document's DOM tree.</p>
4211:
4212: <p>This specification does not define when an interactive user agent
4213: has to render the <code>Document</code> so that it is available to
4214: the user, or when it has to begin accepting user input.</p>
4215:
4216: <p>As each token is emitted from the tokenizer, the user agent must
4217: process the token according to the rules given in the section
4218: corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
4219:
4220: <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
4221: character</dfn> into a node, if that node has a child immediately
4222: before where the character is to be inserted, and that child is a
4223: <code>Text</code> node, and that <code>Text</code> node was the last
4224: node that the parser inserted into the document, then the character
4225: must be appended to that <code>Text</code> node; otherwise, a new
4226: <code>Text</code> node whose data is just that character must be
4227: inserted in the appropriate place.</p>
4228:
4229: <div class="example">
4230:
4231: <p>Here are some sample inputs to the parser and the corresponding
4232: number of text nodes that they result in, assuming a user agent
4233: that executes scripts.</p>
4234:
4235: <table><thead><tr><th>Input </th><th>Number of text nodes
4236: </th></tr></thead><tbody><tr><td><pre>A<script>
4237: var script = document.getElementsByTagName('script')[0];
4238: document.body.removeChild(script);
4239: </script>B</pre>
4240: </td><td>Two adjacent text nodes in the document, containing "A" and "B".
4241: </td></tr><tr><td><pre>A<script>
4242: var text = document.createTextNode('B');
4243: document.body.appendChild(text);
4244: </script>C</pre>
4245: </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
4246: </td></tr><tr><td><pre>A<script>
4247: var text = document.getElementsByTagName('script')[0].firstChild;
4248: text.data = 'B';
4249: document.body.appendChild(text);
4250: </script>B</pre>
4251: </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
4252: </td></tr><tr><td><pre>A<table>B<tr>C</tr>C</table></pre>
4253: </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>.)
4254: </td></tr><tr><td><pre>A<table><tr> B</tr> B</table></pre>
4255: </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>.)
4256: </td></tr><tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
4257: </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.)
4258: </td></tr></tbody></table></div>
4259:
4260: <p id="mutation-during-parsing">DOM mutation events must not fire
4261: for changes caused by the UA parsing the document. (Conceptually,
4262: the parser is not mutating the DOM, it is constructing it.) This
1.159 mike 4263: 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 4264:
4265: <p class="note">Not all of the tag names mentioned below are
4266: conformant tag names in this specification; many are included to
4267: handle legacy content. They still form part of the algorithm that
4268: implementations are required to implement to claim conformance.</p>
4269:
4270: <p class="note">The algorithm described below places no limit on the
4271: depth of the DOM tree generated, or on the length of tag names,
4272: attribute names, attribute values, text nodes, etc. While
4273: implementors are encouraged to avoid arbitrary limits, it is
4274: recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445 mike 4275: concerns</a> will likely force user agents to impose nesting depth
4276: constraints.</p>
1.1 mike 4277:
4278:
1.614 mike 4279: <h5 id="creating-and-inserting-elements"><span class="secno">9.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 4280:
4281: <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
4282: element for the token">create an element for a token</dfn> in a
4283: particular namespace, the UA must create a node implementing the
4284: interface appropriate for the element type corresponding to the tag
4285: name of the token in the given namespace (as given in the
4286: specification that defines that element, e.g. for an <code><a href="text-level-semantics.html#the-a-element">a</a></code>
4287: element in the <a href="#html-namespace-0">HTML namespace</a>, this specification
4288: defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
4289: the tag name being the name of that element, with the node being in
4290: the given namespace, and with the attributes on the node being those
4291: given in the given token.</p>
4292:
4293: <p>The interface appropriate for an element in the <a href="#html-namespace-0">HTML
1.426 mike 4294: namespace</a> that is not defined in this specification (or
4295: <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44 mike 4296: <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1 mike 4297: interface is not defined by that namespace's specification must use
4298: the interface <code>Element</code>.</p>
4299:
4300: <p>When a <a href="forms.html#category-reset" title="category-reset">resettable</a> element is
4301: created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
4302: invoked once the attributes are set. (This initializes the element's
4303: <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
4304: attributes.)</p>
4305:
4306: <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
4307: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
4308: for the token</a> in the <a href="#html-namespace-0">HTML namespace</a>, and then
4309: append this node to the <a href="#current-node">current node</a>, and push it onto
4310: the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
4311: <a href="#current-node">current node</a>.</p>
4312:
4313: <p>The steps below may also require that the UA insert an HTML
4314: element in a particular place, in which case the UA must follow the
4315: same steps except that it must insert or append the new node in the
4316: location specified instead of appending it to the <a href="#current-node">current
4317: node</a>. (This happens in particular during the parsing of
4318: tables with invalid content.)</p>
4319:
4320: <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
4321: algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
4322: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
4323: 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
4324: <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
4325: created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
4326: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
4327: inserting it wherever it is to be inserted.</p>
4328:
4329: <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
4330: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
4331: for the token</a> in the given namespace, and then append this
4332: node to the <a href="#current-node">current node</a>, and push it onto the
4333: <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
4334: <a href="#current-node">current node</a>. If the newly created element has an <code title="">xmlns</code> attribute in the <a href="#xmlns-namespace">XMLNS namespace</a>
4335: whose value is not exactly the same as the element's namespace, that
4336: is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
4337: element has an <code title="">xmlns:xlink</code> attribute in the
4338: <a href="#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="#xlink-namespace">XLink
4339: Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
4340:
4341: <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
4342: attributes</dfn> for a token, then, if the token has an attribute
4343: named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
4344:
4345: <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
4346: attributes</dfn> for a token, then, for each attribute on the token
4347: whose attribute name is one of the ones in the first column of the
4348: following table, change the attribute's name to the name given in
4349: the corresponding cell in the second column. (This fixes the case of
4350: SVG attributes that are not all lowercase.)</p>
4351:
4352: <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
4353: </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
4354: </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
4355: </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
4356: </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
4357: </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
4358: </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
4359: </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
4360: </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
4361: </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
4362: </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
4363: </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
4364: </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
4365: </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
4366: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
4367: </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
4368: </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
4369: </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
4370: </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
4371: </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
4372: </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
4373: </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
4374: </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
4375: </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
4376: </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
4377: </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
4378: </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
4379: </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
4380: </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
4381: </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
4382: </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
4383: </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
4384: </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
4385: </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
4386: </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
4387: </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
4388: </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
4389: </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
4390: </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
4391: </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
4392: </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
4393: </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
4394: </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
4395: </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
4396: </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
4397: </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
4398: </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
4399: </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
4400: </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
4401: </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
4402: </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
4403: </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
4404: </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
4405: </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
4406: </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
4407: </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
4408: </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
4409: </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
4410: </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
4411: </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
4412: </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
4413: </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
4414: </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
4415: </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
4416: foreign attributes</dfn> for a token, then, if any of the attributes
4417: on the token match the strings given in the first column of the
4418: following table, let the attribute be a namespaced attribute, with
4419: the prefix being the string given in the corresponding cell in the
4420: second column, the local name being the string given in the
4421: corresponding cell in the third column, and the namespace being the
4422: namespace given in the corresponding cell in the fourth
4423: column. (This fixes the use of namespaced attributes, in particular
4424: <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
4425: the <span>XML namespace</span></a>.)</p>
4426:
4427: <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
4428: </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="#xlink-namespace">XLink namespace</a>
4429: </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="#xlink-namespace">XLink namespace</a>
4430: </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="#xlink-namespace">XLink namespace</a>
4431: </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="#xlink-namespace">XLink namespace</a>
4432: </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="#xlink-namespace">XLink namespace</a>
4433: </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="#xlink-namespace">XLink namespace</a>
4434: </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="#xlink-namespace">XLink namespace</a>
4435: </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="#xml-namespace">XML namespace</a> <!-- attr-xml-base -->
4436: </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="#xml-namespace">XML namespace</a>
4437: </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="#xml-namespace">XML namespace</a>
4438: </td></tr><tr><td> <code title="">xmlns</code> </td><td> (none) </td><td> <code title="">xmlns</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a>
4439: </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="#xmlns-namespace">XMLNS namespace</a>
1.91 mike 4440: </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 4441: <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
4442: following steps. These algorithms are always invoked in response to
4443: a start tag token.</p>
4444:
4445: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
4446:
1.91 mike 4447: <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541 mike 4448: text element parsing algorithm</a>, switch the tokenizer to the
4449: <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
4450: was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
4451: switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1 mike 4452:
4453: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
4454: <a href="#insertion-mode">insertion mode</a>.</p>
4455:
1.540 mike 4456: </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 4457:
1.614 mike 4458: </ol><h5 id="closing-elements-that-have-implied-end-tags"><span class="secno">9.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 4459:
4460: <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
4461: tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422 mike 4462: <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 4463: <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
4464: <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
4465: <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
4466: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4467: elements</a>.</p>
4468:
4469: <p>If a step requires the UA to generate implied end tags but lists
4470: an element to exclude from the process, then the UA must perform the
4471: above steps as if that element was not in the above list.</p>
4472:
4473:
1.614 mike 4474: <h5 id="foster-parenting"><span class="secno">9.2.5.3 </span>Foster parenting</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 4475:
4476: <p>Foster parenting happens when content is misnested in tables.</p>
4477:
4478: <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
4479: parent">foster parented</dfn>, the node <var title="">node</var>
4480: must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4481:
4482: <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
4483: 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
4484: elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
4485: such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4486: the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
4487: case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
4488: element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159 mike 4489: <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1 mike 4490: <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
4491: elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4492: <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
4493: node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
4494: the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4495: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
4496:
4497: <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
4498: 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
4499: elements</a>, then <var title="">node</var> must be inserted
4500: immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4501: the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
4502: element</a></i>; otherwise, <var title="">node</var> must be
4503: <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4504:
4505:
4506:
1.614 mike 4507: <h5 id="the-initial-insertion-mode"><span class="secno">9.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 4508:
4509: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
4510: mode: initial">initial</a>", tokens must be handled as follows:</p>
4511:
4512: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4513: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4514: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4515: <dd>
4516: <p>Ignore the token.</p>
4517: </dd>
4518:
4519: <dt>A comment token</dt>
4520: <dd>
4521: <p>Append a <code>Comment</code> node to the <code>Document</code>
4522: object with the <code title="">data</code> attribute set to the
4523: data given in the comment token.</p>
4524: </dd>
4525:
4526: <dt>A DOCTYPE token</dt>
4527: <dd>
4528:
4529: <p>If the DOCTYPE token's name is not a
4530: <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
4531: missing, or the token's system identifier is neither missing nor a
4532: <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465 mike 4533: "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1 mike 4534: conditions in the following list are matched, then there is a
4535: <a href="#parse-error">parse error</a>. If one of the sets of conditions in the
4536: following list is matched, then there is an <dfn id="obsolete-permitted-doctype">obsolete
4537: permitted DOCTYPE</dfn>.</p>
4538:
4539: <ul><!-- only things that trigger no-quirks mode and were valid in
4540: some other spec are allowed in this list --><li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98 mike 4541: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4542: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD HTML 4.0//EN</code>", and the
4543: token's system identifier is either missing or the
4544: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
4545:
4546: <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98 mike 4547: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4548: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD HTML 4.01//EN</code>", and the
4549: token's system identifier is either missing or the
4550: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
4551:
4552: <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98 mike 4553: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4554: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>",
4555: and the token's system identifier is the
4556: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
4557:
4558: <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98 mike 4559: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4560: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD XHTML 1.1//EN</code>", and the
4561: token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4562: string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
4563:
4564: </ul><p>Conformance checkers may, based on the values (including
4565: presence or lack thereof) of the DOCTYPE token's name, public
4566: identifier, or system identifier, switch to a conformance checking
4567: mode for another language (e.g. based on the DOCTYPE token a
4568: conformance checker could recognize that the document is an
1.183 mike 4569: HTML4-era document, and defer to an HTML4 conformance
1.1 mike 4570: checker.)</p>
4571:
4572: <p>Append a <code>DocumentType</code> node to the
4573: <code>Document</code> node, with the <code title="">name</code>
4574: attribute set to the name given in the DOCTYPE token, or the empty
4575: string if the name was missing; the <code title="">publicId</code>
4576: attribute set to the public identifier given in the DOCTYPE token,
4577: or the empty string if the public identifier was missing; the
4578: <code title="">systemId</code> attribute set to the system
4579: identifier given in the DOCTYPE token, or the empty string if the
4580: system identifier was missing; and the other attributes specific
4581: to <code>DocumentType</code> objects set to null and empty lists
4582: as appropriate. Associate the <code>DocumentType</code> node with
4583: the <code>Document</code> object so that it is returned as the
4584: value of the <code title="">doctype</code> attribute of the
4585: <code>Document</code> object.</p>
4586:
4587: <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
4588: one of the conditions in the following list, then set the
4589: <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
4590:
4591: <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
4592: <li> The name is set to anything other than "<code title="">HTML</code>". </li>
4593: <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
4594: <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4595: <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4596: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
4597: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
4598: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
4599: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
4600: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
4601: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
4602: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
4603: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
4604: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
4605: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4606: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
4607: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
4608: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
4609: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
4610: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
4611: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
4612: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
4613: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
4614: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
4615: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
4616: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
4617: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
4618: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
4619: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
4620: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
4621: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
4622: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
4623: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
4624: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
4625: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
4626: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
4627: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
4628: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
4629: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
4630: <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
4631: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
4632: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
4633: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
4634: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
4635: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
4636: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
4637: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
4638: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
4639: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
4640: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
4641: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
4642: <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
4643: <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
4644: <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
4645: <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
4646: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
4647: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
4648: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
4649: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
4650: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4651: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
4652: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
4653: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
4654: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
4655: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
4656: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
4657: <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
4658: <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
4659: <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>-->
4660: <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
4661: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
4662: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
4663: <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
4664: <li> The public identifier is set to: "<code title="">HTML</code>" </li>
4665: <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
4666: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4667: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
4668: </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
4669: in the following list, then set the <code>Document</code> to
4670: <a href="dom.html#limited-quirks-mode">limited quirks mode</a>:</p>
4671:
4672: <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
4673: <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
4674: <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4675: <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
4676: </ul><p>The name, system identifier, and public identifier strings must
4677: be compared to the values given in the lists above in an
4678: <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> manner. A system identifier
4679: whose value is the empty string is not considered missing for the
4680: purposes of the conditions above.</p>
4681:
4682: <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>
4683:
4684: </dd>
4685:
4686: <dt>Anything else</dt>
4687: <dd>
4688:
4689: <p><a href="#parse-error">Parse error</a>.</p>
4690:
4691: <p>Set the <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
4692:
4693: <p>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
4694: reprocess the current token.</p>
4695:
4696: </dd>
4697:
1.614 mike 4698: </dl><h5 id="the-before-html-insertion-mode"><span class="secno">9.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 4699:
4700: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
4701: mode: before html">before html</a>", tokens must be handled as follows:</p>
4702:
4703: <dl class="switch"><dt>A DOCTYPE token</dt>
4704: <dd>
4705: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4706: </dd>
4707:
4708: <dt>A comment token</dt>
4709: <dd>
4710: <p>Append a <code>Comment</code> node to the <code>Document</code>
4711: object with the <code title="">data</code> attribute set to the
4712: data given in the comment token.</p>
4713: </dd>
4714:
4715: <dt>A character token that is one of U+0009 CHARACTER
4716: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4717: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4718: <dd>
4719: <p>Ignore the token.</p>
4720: </dd>
4721:
4722: <dt>A start tag whose tag name is "html"</dt>
4723: <dd>
4724:
4725: <p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the <a href="#html-namespace-0">HTML
4726: namespace</a>. Append it to the <code>Document</code>
4727: object. Put this element in the <a href="#stack-of-open-elements">stack of open
4728: elements</a>.</p>
4729:
4730: <p id="parser-appcache">If the <code>Document</code> is being
4731: loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
4732: <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
4733: has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute,
4734: then <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolve</a> the value of that
4735: attribute to an <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly
4736: 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 4737: algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
4738: any <a href="infrastructure.html#url-fragment" title="url-fragment"><fragment></a> component
4739: removed; otherwise, if there is no such attribute or resolving it
4740: fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application
4741: cache selection algorithm</a> with no manifest. The algorithm
4742: must be passed the <code>Document</code> object.</p>
1.1 mike 4743:
4744: <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>
4745:
4746: </dd>
4747:
1.334 mike 4748: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4749: <dd>
4750: <p>Act as described in the "anything else" entry below.</p>
4751: </dd>
4752:
4753: <dt>Any other end tag</dt>
4754: <dd>
4755: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4756: </dd>
4757:
1.1 mike 4758: <dt>Anything else</dt>
4759: <dd>
4760:
1.159 mike 4761: <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.1 mike 4762: <code>Document</code> object. Put this element in the <a href="#stack-of-open-elements">stack
4763: of open elements</a>.</p>
4764:
4765: <p>If the <code>Document</code> is being loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a <a href="browsers.html#browsing-context">browsing
4766: context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
4767: algorithm</a> with no manifest, passing it the
4768: <code>Document</code> object.</p>
4769:
4770: <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
4771: reprocess the current token.</p>
4772:
4773: </dd>
4774:
4775: </dl><p>The root element can end up being removed from the
4776: <code>Document</code> object, e.g. by scripts; nothing in particular
4777: happens in such cases, content continues being appended to the nodes
4778: as described in the next section.</p>
4779:
4780:
1.614 mike 4781: <h5 id="the-before-head-insertion-mode"><span class="secno">9.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 4782:
4783: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
4784: mode: before head">before head</a>", tokens must be handled as follows:</p>
4785:
4786: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4787: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4788: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4789: <dd>
4790: <p>Ignore the token.</p> <!-- :-( -->
4791: </dd>
4792:
4793: <dt>A comment token</dt>
4794: <dd>
4795: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
4796: node</a> with the <code title="">data</code> attribute set to
4797: the data given in the comment token.</p>
4798: </dd>
4799:
4800: <dt>A DOCTYPE token</dt>
4801: <dd>
4802: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4803: </dd>
4804:
4805: <dt>A start tag whose tag name is "html"</dt>
4806: <dd>
4807: <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
4808: mode</a>.</p>
4809: </dd>
4810:
4811: <dt>A start tag whose tag name is "head"</dt>
4812: <dd>
4813:
4814: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
4815:
4816: <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159 mike 4817: to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 4818:
4819: <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>
4820:
4821: </dd>
4822:
4823: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4824: <dd>
4825:
4826: <p>Act as if a start tag token with the tag name "head" and no
4827: attributes had been seen, then reprocess the current token.</p>
4828:
4829: </dd>
4830:
4831: <dt>Any other end tag</dt>
4832: <dd>
4833:
4834: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4835:
4836: </dd>
4837:
4838: <dt>Anything else</dt>
4839: <dd>
4840:
4841: <p>Act as if a start tag token with the tag name "head" and no
4842: attributes had been seen, then reprocess the current
4843: token.</p>
4844:
4845: </dd>
4846:
1.614 mike 4847: </dl><h5 id="parsing-main-inhead"><span class="secno">9.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 4848:
4849: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
4850: mode: in head">in head</a>", tokens must be handled as follows:</p>
4851:
4852: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4853: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4854: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4855: <dd>
4856: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
4857: the <a href="#current-node">current node</a>.</p>
4858: </dd>
4859:
4860: <dt>A comment token</dt>
4861: <dd>
4862: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
4863: node</a> with the <code title="">data</code> attribute set to
4864: the data given in the comment token.</p>
4865: </dd>
4866:
4867: <dt>A DOCTYPE token</dt>
4868: <dd>
4869: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4870: </dd>
4871:
4872: <dt>A start tag whose tag name is "html"</dt>
4873: <dd>
4874: <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
4875: mode</a>.</p>
4876: </dd>
4877:
4878: <dt>A start tag whose tag name is one of: "base", "command",
4879: "link"</dt>
4880: <dd>
4881:
4882: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
4883: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4884: elements</a>.</p>
4885:
4886: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
4887: token's <i>self-closing flag</i></a>, if it is set.</p>
4888:
4889: </dd>
4890:
4891: <dt>A start tag whose tag name is "meta"</dt>
4892: <dd>
4893:
4894: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
4895: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4896: elements</a>.</p>
4897:
4898: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
4899: token's <i>self-closing flag</i></a>, if it is set.</p>
4900:
4901: <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
4902: value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
4903: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
4904: encoding</a> to the encoding given by the value of the
4905: <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
4906:
4907: <p>Otherwise, if the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">content</a></code> attribute, and
4908: applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
4909: Content-Type</a> to its value returns a supported encoding
4910: <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
4911: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
4912: encoding</a> to the encoding <var title="">encoding</var>.</p>
4913:
4914: </dd>
4915:
4916: <dt>A start tag whose tag name is "title"</dt>
4917: <dd>
4918: <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
4919: </dd>
4920:
4921: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
4922: <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
4923: <dd>
1.91 mike 4924: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 4925: </dd>
4926:
4927: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
4928: <dd>
4929:
4930: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
4931:
4932: <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
4933: noscript</a>".</p>
4934:
4935: </dd>
4936:
4937: <dt id="scriptTag">A start tag whose tag name is "script"</dt>
4938: <dd>
4939:
4940: <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
4941: <a href="#html-namespace-0">HTML namespace</a>.</p></li>
4942:
4943: <li>
4944:
4945: <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
4946:
4947: <p class="note">This ensures that, if the script is external,
1.159 mike 4948: any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1 mike 4949: calls in the script will execute in-line, instead of blowing the
4950: document away, as would happen in most other cases. It also
4951: prevents the script from executing until the end tag is
4952: seen.</p>
4953:
4954: </li>
4955:
4956: <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
4957: fragment parsing algorithm</a>, then mark the
1.484 mike 4958: <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
4959: started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1 mike 4960:
4961: <li><p>Append the new element to the <a href="#current-node">current node</a>
4962: and push it onto the <a href="#stack-of-open-elements">stack of open
4963: elements</a>.</p></li>
4964:
1.541 mike 4965: <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
4966: state</a>.</p></li>
1.1 mike 4967:
4968: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
4969: <a href="#insertion-mode">insertion mode</a>.</p>
4970:
1.540 mike 4971: </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 4972:
4973: </ol></dd>
4974:
4975: <dt>An end tag whose tag name is "head"</dt>
4976: <dd>
4977:
4978: <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159 mike 4979: <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 4980: elements</a>.</p>
4981:
4982: <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>
4983:
4984: </dd>
4985:
4986: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
4987: <dd>
4988: <p>Act as described in the "anything else" entry below.</p>
4989: </dd>
4990:
4991: <dt>A start tag whose tag name is "head"</dt>
4992: <dt>Any other end tag</dt>
4993: <dd>
4994: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4995: </dd>
4996:
4997: <dt>Anything else</dt>
4998: <dd>
4999:
5000: <!-- can't get here with an EOF and a fragment case -->
5001:
5002: <p>Act as if an end tag token with the tag name "head" had
5003: been seen, and reprocess the current token.</p>
5004:
5005: </dd>
5006:
1.614 mike 5007: </dl><h5 id="parsing-main-inheadnoscript"><span class="secno">9.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 5008:
5009: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
5010: mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
5011:
5012: <dl class="switch"><dt>A DOCTYPE token</dt>
5013: <dd>
5014: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5015: </dd>
5016:
5017: <dt>A start tag whose tag name is "html"</dt>
5018: <dd>
5019: <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
5020: mode</a>.</p>
5021: </dd>
5022:
5023: <dt>An end tag whose tag name is "noscript"</dt>
5024: <dd>
5025:
5026: <p>Pop the <a href="#current-node">current node</a> (which will be a
5027: <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
5028: elements</a>; the new <a href="#current-node">current node</a> will be a
1.159 mike 5029: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 5030:
5031: <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>
5032:
5033: </dd>
5034:
5035: <dt>A character token that is one of U+0009 CHARACTER
5036: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
5037: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
5038: <dt>A comment token</dt>
5039: <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
5040: <dd>
5041: <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
5042: mode</a>.</p>
5043: </dd>
5044:
5045: <dt>An end tag whose tag name is "br"</dt>
5046: <dd>
5047: <p>Act as described in the "anything else" entry below.</p>
5048: </dd>
5049:
5050: <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
5051: <dt>Any other end tag</dt>
5052: <dd>
5053: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5054: </dd>
5055:
5056: <dt>Anything else</dt>
5057: <dd>
5058:
5059: <!-- can't get here with an EOF and a fragment case -->
5060:
5061: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
5062: name "noscript" had been seen and reprocess the current
5063: token.</p>
5064:
5065: </dd>
5066:
1.614 mike 5067: </dl><h5 id="the-after-head-insertion-mode"><span class="secno">9.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 5068:
5069: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
5070: mode: after head">after head</a>", tokens must be handled as follows:</p>
5071:
5072: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
5073: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
5074: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
5075: <dd>
5076: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
5077: the <a href="#current-node">current node</a>.</p>
5078: </dd>
5079:
5080: <dt>A comment token</dt>
5081: <dd>
5082: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
5083: node</a> with the <code title="">data</code> attribute set to
5084: the data given in the comment token.</p>
5085: </dd>
5086:
5087: <dt>A DOCTYPE token</dt>
5088: <dd>
5089: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5090: </dd>
5091:
5092: <dt>A start tag whose tag name is "html"</dt>
5093: <dd>
5094: <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
5095: mode</a>.</p>
5096: </dd>
5097:
5098: <dt>A start tag whose tag name is "body"</dt>
5099: <dd>
5100:
5101: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5102:
5103: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5104:
5105: <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>
5106:
5107: </dd>
5108:
5109: <dt>A start tag whose tag name is "frameset"</dt>
5110: <dd>
5111:
5112: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5113:
5114: <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>
5115:
5116: </dd>
5117:
5118: <dt>A start tag token whose tag name is one of: "base", "link",
5119: "meta", "noframes", "script", "style", "title"</dt>
5120: <dd>
5121:
5122: <p><a href="#parse-error">Parse error</a>.</p>
5123:
5124: <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
5125: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5126:
5127: <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
5128: mode</a>.</p>
5129:
5130: <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
5131: of open elements</a>.</p>
5132:
5133: <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
5134: pointer</a> cannot be null at this point.</p>
5135:
5136: </dd>
5137:
5138: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5139: <dd>
5140: <p>Act as described in the "anything else" entry below.</p>
5141: </dd>
5142:
5143: <dt>A start tag whose tag name is "head"</dt>
5144: <dt>Any other end tag</dt>
5145: <dd>
5146: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5147: </dd>
5148:
5149: <dt>Anything else</dt>
5150: <dd>
5151: <p>Act as if a start tag token with the tag name "body" and no
5152: attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
5153: flag</a> back to "ok", and then reprocess the current
5154: token.</p>
5155: </dd>
5156:
1.614 mike 5157: </dl><h5 id="parsing-main-inbody"><span class="secno">9.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 5158:
5159: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
5160: mode: in body">in body</a>", tokens must be handled as follows:</p>
5161:
5162: <dl class="switch"><dt>A character token</dt>
5163: <dd>
5164:
5165: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5166: any.</p>
5167:
5168: <p><a href="#insert-a-character" title="insert a character">Insert the token's
5169: character</a> into the <a href="#current-node">current node</a>.</p>
5170:
5171: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
5172: LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
5173: (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
5174: flag</a> to "not ok".</p>
5175:
5176: </dd>
5177:
5178: <dt>A comment token</dt>
5179: <dd>
5180: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
5181: node</a> with the <code title="">data</code> attribute set to
5182: the data given in the comment token.</p>
5183: </dd>
5184:
5185: <dt>A DOCTYPE token</dt>
5186: <dd>
5187: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5188: </dd>
5189:
5190: <dt>A start tag whose tag name is "html"</dt>
5191: <dd>
5192: <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
5193: check to see if the attribute is already present on the top
5194: element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
5195: add the attribute and its corresponding value to that element.</p>
5196: </dd>
5197:
5198: <dt>A start tag token whose tag name is one of: "base", "command",
5199: "link", "meta", "noframes", "script", "style", "title"</dt>
5200: <dd>
5201: <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
5202: mode</a>.</p>
5203: </dd>
5204:
5205: <dt>A start tag whose tag name is "body"</dt>
5206: <dd>
5207:
5208: <p><a href="#parse-error">Parse error</a>.</p>
5209:
5210: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5211: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5212: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5213: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5214:
5215: <p>Otherwise, for each attribute on the token, check to see if
1.159 mike 5216: the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 5217: element (the second element) on the <a href="#stack-of-open-elements">stack of open
5218: elements</a>. If it is not, add the attribute and its
5219: corresponding value to that element.</p>
5220:
5221: </dd>
5222:
5223: <dt>A start tag whose tag name is "frameset"</dt>
5224: <dd>
5225:
5226: <p><a href="#parse-error">Parse error</a>.</p>
5227:
5228: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5229: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5230: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5231: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5232:
5233: <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
5234: the token.</p>
5235:
5236: <p>Otherwise, run the following steps:</p>
5237:
5238: <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
5239: elements</a> from its parent node, if it has one.</p></li>
5240:
5241: <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
5242: open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159 mike 5243: but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1 mike 5244:
5245: </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
5246: token.</p></li>
5247:
5248: <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>
5249:
5250: </li></ol></dd>
5251:
5252: <dt>An end-of-file token</dt>
5253: <dd>
5254:
5255: <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422 mike 5256: 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>
5257: 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 5258: <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
5259: <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
5260: <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 5261: <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 5262: this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422 mike 5263: fragment cases) -->
1.1 mike 5264:
5265: <p><a href="#stop-parsing">Stop parsing</a>.</p>
5266:
5267: </dd>
5268:
5269: <dt>An end tag whose tag name is "body"</dt>
5270: <dd>
5271:
5272: <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
5273: in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
5274: token.</p>
5275:
5276: <!-- if we get here, the insertion mode here is forcibly "in
5277: body". -->
5278:
5279: <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422 mike 5280: elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1 mike 5281: <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
5282: <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
5283: <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
5284: <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
5285: <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
5286: <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 5287: <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
5288: <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 5289: error</a>.</p> <!-- (some of those are fragment cases, e.g. for
5290: <tbody> you'd have hit the first paragraph since the <body>
1.422 mike 5291: wouldn't be in scope, unless it was a fragment case) -->
1.1 mike 5292:
5293: <!-- If we ever change the frameset-ok flag to an insertion mode,
5294: then we'd have to somehow keep track of its state when we switch
5295: to after-body. -->
5296:
5297: <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>
5298:
5299: </dd>
5300:
5301: <dt>An end tag whose tag name is "html"</dt>
5302: <dd>
5303:
5304: <p>Act as if an end tag with tag name "body" had been seen,
5305: then, if that token wasn't ignored, reprocess the current
5306: token.</p>
5307:
5308: <p class="note">The fake end tag token here can only be
5309: ignored in the <a href="#fragment-case">fragment case</a>.</p>
5310:
5311: </dd>
5312:
5313: <!-- start tags for non-phrasing flow content elements -->
5314:
5315: <!-- the normal ones -->
5316: <dt>A start tag whose tag name is one of: "address", "article",
1.86 mike 5317: "aside", "blockquote", "center", <!--v2DATAGRID-->"datagrid",
1.305 mike 5318: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5319: "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1 mike 5320: <dd>
5321:
5322: <!-- As of May 2008 this doesn't match any browser exactly, but is
5323: as close to what IE does as I can get without doing the non-tree
5324: DOM nonsense, and thus should actually afford better compatibility
5325: when implemented by the other browsers. -->
5326:
5327: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5328: an element in scope">has a <code>p</code> element in
5329: scope</a>, then act as if an end tag with the tag name
5330: "p" had been seen.</p>
5331:
5332: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5333:
5334: </dd>
5335:
5336: <!-- as normal, but close h1-h6 if it's the current node -->
5337: <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
5338: "h5", "h6"</dt>
5339: <dd>
5340:
5341: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5342: an element in scope">has a <code>p</code> element in
5343: scope</a>, then act as if an end tag with the tag name
5344: "p" had been seen.</p>
5345:
5346: <p>If the <a href="#current-node">current node</a> is an element whose tag name
5347: is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
5348: <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
5349: the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5350: <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
5351:
5352: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5353:
5354: </dd>
5355:
5356: <!-- as normal, but drops leading newline -->
5357: <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
5358: <dd>
5359:
5360: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5361: an element in scope">has a <code>p</code> element in
5362: scope</a>, then act as if an end tag with the tag name
5363: "p" had been seen.</p>
5364:
5365: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5366:
5367: <p>If the next token is a U+000A LINE FEED (LF) character
5368: token, then ignore that token and move on to the next
5369: one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
5370: ignored as an authoring convenience.)</p>
5371:
5372: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5373:
5374: </dd>
5375:
5376: <!-- as normal, but interacts with the form element pointer -->
5377: <dt>A start tag whose tag name is "form"</dt>
5378: <dd>
5379:
5380: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
5381: pointer</a> is not null, then this is a <a href="#parse-error">parse
5382: error</a>; ignore the token.</p>
5383:
5384: <p>Otherwise:</p>
5385:
5386: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5387: an element in scope">has a <code>p</code> element in
5388: scope</a>, then act as if an end tag with the tag name
5389: "p" had been seen.</p>
5390:
5391: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
5392: <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
5393: point to the element created.</p>
5394:
5395: </dd>
5396:
5397: <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
5398: <dt>A start tag whose tag name is "li"</dt>
5399: <dd>
5400:
5401: <p>Run the following algorithm:</p>
5402:
5403: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5404:
5405: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5406: node</a> (the bottommost node of the stack).</p></li>
5407:
1.578 mike 5408: <li><p><i>Loop</i>: If <var title="">node</var> is an
5409: <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
5410: name "li" had been seen, then jump to the last step.</p></li>
1.1 mike 5411:
1.578 mike 5412: <li><p>If <var title="">node</var> is not in the
1.1 mike 5413: <a href="#formatting">formatting</a> category, and is not in the
5414: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5415: <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 5416: element, then jump to the last step.</p></li> <!-- an element
5417: <foo> is in this list if the following markup:
5418:
5419: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
5420:
5421: ...results in the second <li> not being (in any way) a descendant
5422: of the first <li>, or if <foo> is a formatting element that gets
5423: reopened later. -->
5424:
5425: <li><p>Otherwise, set <var title="">node</var> to the previous
5426: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5427: the step labeled <i>loop</i>.</p></li>
5428:
5429: <li>
5430:
5431: <p>This is the last step.</p>
5432:
5433: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5434: an element in scope">has a <code>p</code> element in
5435: scope</a>, then act as if an end tag with the tag name
5436: "p" had been seen.</p>
5437:
5438: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5439: token.</p>
5440:
5441: </li>
5442:
5443: </ol></dd>
5444:
5445: <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases -->
1.422 mike 5446: <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5447: <dd>
5448:
5449: <p>Run the following algorithm:</p>
5450:
5451: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5452:
5453: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5454: node</a> (the bottommost node of the stack).</p></li>
5455:
5456: <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422 mike 5457: <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
5458: tag with the same tag name as <var title="">node</var> had been
5459: seen, then jump to the last step.</p></li>
1.1 mike 5460:
5461: <li><p>If <var title="">node</var> is not in the
5462: <a href="#formatting">formatting</a> category, and is not in the
5463: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5464: <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 5465: element, then jump to the last step.</p></li> <!-- an element
5466: <foo> is in this list if the following markup:
5467:
5468: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
5469:
5470: ...results in the second <dt> not being (in any way) a descendant
5471: of the first <dt>, or if <foo> is a formatting element that gets
5472: reopened later. -->
5473:
5474: <li><p>Otherwise, set <var title="">node</var> to the previous
5475: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5476: the step labeled <i>loop</i>.</p></li>
5477:
5478: <li>
5479:
5480: <p>This is the last step.</p>
5481:
5482: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5483: an element in scope">has a <code>p</code> element in
5484: scope</a>, then act as if an end tag with the tag name
5485: "p" had been seen.</p>
5486:
5487: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5488: token.</p>
5489:
5490: </li>
5491:
5492: </ol></dd>
5493:
5494: <!-- same as normal, but effectively ends parsing -->
5495: <dt>A start tag whose tag name is "plaintext"</dt>
5496: <dd>
5497:
5498: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5499: an element in scope">has a <code>p</code> element in
5500: scope</a>, then act as if an end tag with the tag name
5501: "p" had been seen.</p>
5502:
5503: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5504:
1.541 mike 5505: <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5506:
1.541 mike 5507: <p class="note">Once a start tag with the tag name "plaintext" has
5508: been seen, that will be the last token ever seen other than
5509: character tokens (and the end-of-file token), because there is no
5510: way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5511:
5512: </dd>
5513:
5514: <!-- end tags for non-phrasing flow content elements -->
5515:
5516: <!-- the normal ones -->
5517: <dt>An end tag whose tag name is one of: "address", "article",
1.86 mike 5518: "aside", "blockquote", "center", <!--v2DATAGRID-->"datagrid",
1.305 mike 5519: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5520: "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
5521: "section", "ul"</dt>
1.1 mike 5522: <dd>
5523:
5524: <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>
5525: with the same tag name as that of the token, then this is a
5526: <a href="#parse-error">parse error</a>; ignore the token.</p>
5527:
5528: <p>Otherwise, run these steps:</p>
5529:
5530: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5531:
5532: <li><p>If the <a href="#current-node">current node</a> is not an element with
5533: the same tag name as that of the token, then this is a
5534: <a href="#parse-error">parse error</a>.</p></li>
5535:
5536: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5537: until an element with the same tag name as the token has been
5538: popped from the stack.</p></li>
5539:
5540: </ol></dd>
5541:
5542: <!-- removes the form element pointer instead of the matching node -->
5543: <dt>An end tag whose tag name is "form"</dt>
5544: <dd>
5545:
5546: <p>Let <var title="">node</var> be the element that the
5547: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
5548: to.</p>
5549:
5550: <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
5551: to null.</p>
5552:
5553: <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
5554: elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
5555: scope">have <var title="">node</var> in scope</a>, then this is
5556: a <a href="#parse-error">parse error</a>; ignore the token.</p>
5557:
5558: <p>Otherwise, run these steps:</p>
5559:
5560: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5561:
5562: <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
5563: error</a>.</p></li>
5564:
5565: <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
5566: open elements</a>.</p></li>
5567:
5568: </ol></dd>
5569:
5570: <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
5571: <dt>An end tag whose tag name is "p"</dt>
5572: <dd>
5573:
5574: <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>
5575: with the same tag name as that of the token, then this is a
5576: <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
5577: "p" had been seen, then reprocess the current token.</p>
5578:
5579: <p>Otherwise, run these steps:</p>
5580:
5581: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5582: for elements with the same tag name as the token.</p></li>
5583:
5584: <li><p>If the <a href="#current-node">current node</a> is not an element with
5585: the same tag name as that of the token, then this is a
5586: <a href="#parse-error">parse error</a>.</p></li>
5587:
5588: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5589: until an element with the same tag name as the token has been
5590: popped from the stack.</p></li>
5591:
5592: </ol></dd>
5593:
1.234 mike 5594: <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
5595: <dt>An end tag whose tag name is "li"</dt>
5596: <dd>
5597:
5598: <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
5599: item scope</a> with the same tag name as that of the token,
5600: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5601:
5602: <p>Otherwise, run these steps:</p>
5603:
5604: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5605: for elements with the same tag name as the token.</p></li>
5606:
5607: <li><p>If the <a href="#current-node">current node</a> is not an element with
5608: the same tag name as that of the token, then this is a
5609: <a href="#parse-error">parse error</a>.</p></li>
5610:
5611: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5612: until an element with the same tag name as the token has been
5613: popped from the stack.</p></li>
5614:
5615: </ol></dd>
5616:
1.1 mike 5617: <!-- as normal, but needs care as the elements have optional tags -->
1.422 mike 5618: <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5619: <dd>
5620:
5621: <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>
5622: with the same tag name as that of the token, then this is a
5623: <a href="#parse-error">parse error</a>; ignore the token.</p>
5624:
5625: <p>Otherwise, run these steps:</p>
5626:
5627: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5628: for elements with the same tag name as the token.</p></li>
5629:
5630: <li><p>If the <a href="#current-node">current node</a> is not an element with
5631: the same tag name as that of the token, then this is a
5632: <a href="#parse-error">parse error</a>.</p></li>
5633:
5634: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5635: until an element with the same tag name as the token has been
5636: popped from the stack.</p></li>
5637:
5638: </ol></dd>
5639:
5640: <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
5641: <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
5642: <dd>
5643:
5644: <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>
5645: whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
5646: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5647:
5648: <p>Otherwise, run these steps:</p>
5649:
5650: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5651:
5652: <li><p>If the <a href="#current-node">current node</a> is not an element with
5653: the same tag name as that of the token, then this is a
5654: <a href="#parse-error">parse error</a>.</p></li>
5655:
5656: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5657: until an element whose tag name is one of "h1", "h2", "h3", "h4",
5658: "h5", or "h6" has been popped from the stack.</p></li>
5659:
5660: </ol></dd>
5661:
5662: <dt>An end tag whose tag name is "sarcasm"</dt>
5663: <dd>
5664: <p>Take a deep breath, then act as described in the "any other end
5665: tag" entry below.</p>
5666: </dd>
5667:
5668: <!-- ADOPTION AGENCY ELEMENTS
5669: Mozilla-only: bdo blink del ins sub sup q
5670: Safari-only: code dfn kbd nobr samp var wbr
5671: Both: a b big em font i s small strike strong tt u -->
5672:
5673: <dt>A start tag whose tag name is "a"</dt>
5674: <dd>
5675:
5676: <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
5677: contains an element whose tag name is "a" between the end of
5678: the list and the last marker on the list (or the start of the
5679: list if there is no marker on the list), then this is a
5680: <a href="#parse-error">parse error</a>; act as if an end tag with the tag
5681: name "a" had been seen, then remove that element from the
5682: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
5683: <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
5684: already remove it (it might not have if the element is not
5685: <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
5686: scope</a>).</p>
5687:
5688: <p class="example">In the non-conforming stream
5689: <code><a href="a">a<table><a href="b">b</table>x</code>,
5690: the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing
5691: the second one, and the "x" character would be inside a link
5692: to "b", not to "a". This is despite the fact that the outer
5693: <code><a href="text-level-semantics.html#the-a-element">a</a></code> element is not in table scope (meaning that a
5694: regular <code></a></code> end tag at the start of the table
5695: wouldn't close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element).</p>
5696:
5697: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5698: any.</p>
5699:
5700: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5701: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5702: elements</a>.</p>
5703:
5704: </dd>
5705:
5706: <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
5707: "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
5708: <dd>
5709:
5710: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5711: any.</p>
5712:
5713: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5714: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5715: elements</a>.</p>
5716:
5717: </dd>
5718:
5719: <dt>A start tag whose tag name is "nobr"</dt>
5720: <dd>
5721:
5722: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5723: any.</p>
5724:
5725: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
5726: element in scope">has a <code>nobr</code> element in scope</a>,
5727: then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
5728: the tag name "nobr" had been seen, then once again
5729: <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
5730: any.</p>
5731:
5732: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5733: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5734: elements</a>.</p>
5735:
5736: </dd>
5737:
5738: <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
5739: "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
5740: "strike", "strong", "tt", "u"</dt>
5741: <dd>
5742:
5743: <p>Follow these steps:</p>
5744:
5745: <ol><li>
5746:
5747: <p>Let the <var title="">formatting element</var> be the
5748: last element in the <a href="#list-of-active-formatting-elements">list of active formatting
5749: elements</a> that:</p>
5750:
5751: <ul><li>is between the end of the list and the last scope
5752: marker in the list, if any, or the start of the list
5753: otherwise, and</li>
5754:
5755: <li>has the same tag name as the token.</li>
5756:
5757: </ul><p>If there is no such node, or, if that node is also in the
5758: <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
5759: <a href="#parse-error">parse error</a>; ignore the token, and abort these
5760: steps.</p>
5761:
5762: <p>Otherwise, if there is such a node, but that node is not
5763: in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
5764: <a href="#parse-error">parse error</a>; remove the element from the list,
5765: and abort these steps.</p>
5766:
5767: <p>Otherwise, there is a <var title="">formatting
5768: element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
5769: open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
5770: element in scope">in scope</a>. If the element is not the
5771: <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
5772: error</a>. In any case, proceed with the algorithm as
5773: written in the following steps.</p>
5774:
5775: </li>
5776:
5777: <li><p>Let the <var title="">furthest block</var> be the
5778: topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
5779: is lower in the stack than the <var title="">formatting
5780: element</var>, and is not an element in the
5781: <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
5782: categories. There might not be one.</p></li>
5783:
5784: <li><p>If there is no <var title="">furthest block</var>,
5785: then the UA must skip the subsequent steps and instead just
5786: pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
5787: elements</a>, from the <a href="#current-node">current node</a> up to and
5788: including the <var title="">formatting element</var>, and
5789: remove the <var title="">formatting element</var> from the
5790: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
5791:
5792: <li><p>Let the <var title="">common ancestor</var> be the element
5793: immediately above the <var title="">formatting element</var> in the
5794: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
5795:
5796: <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
5797: formatting elements</a> relative to the elements on either
5798: side of it in the list.</p></li>
5799:
5800: <li>
5801:
5802: <p>Let <var title="">node</var> and <var title="">last node</var> be the
5803: <var title="">furthest block</var>. Follow these steps:</p>
5804:
5805: <ol><li>Let <var title="">node</var> be the element immediately
5806: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436 mike 5807: elements</a>, or if <var title="">node</var> is no longer in
5808: the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
5809: removed by the next step), the element that was immediately
5810: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
5811: elements</a> before <var title="">node</var> was
5812: removed.</li>
1.1 mike 5813:
5814: <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
5815: active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
5816: elements</a> and then go back to step 1.</li>
5817:
5818: <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
5819: in the overall algorithm.</li>
5820:
5821: <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
5822: bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
5823: elements</a>.</li>
5824:
5825: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
5826: element <var title="">node</var> was created, replace the entry
5827: for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
5828: formatting elements</a> with an entry for the new element,
5829: replace the entry for <var title="">node</var> in the
5830: <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
5831: element, and let <var title="">node</var> be the new
5832: element.</li>
5833:
5834: <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
5835: parent node if any.</li>
5836:
5837: <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
5838:
5839: <li>Return to step 1 of this inner set of steps.</li>
5840:
5841: </ol></li>
5842:
5843: <li>
5844:
5845: <p>If the <var title="">common ancestor</var> node is a
5846: <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>,
5847: <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,
5848: <a href="#foster-parent">foster parent</a> whatever <var title="">last
5849: node</var> ended up being in the previous step, first removing
5850: it from its previous parent node if any.</p>
5851:
5852: <p>Otherwise, append whatever <var title="">last node</var>
5853: ended up being in the previous step to the <var title="">common
5854: ancestor</var> node, first removing it from its previous parent
5855: node if any.</p>
5856:
5857: </li>
5858:
5859: <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
5860: <var title="">formatting element</var> was created.</p></li>
5861:
5862: <li><p>Take all of the child nodes of the <var title="">furthest
5863: block</var> and append them to the element created in the last
5864: step.</p></li>
5865:
5866: <li><p>Append that new element to the <var title="">furthest
5867: block</var>.</p></li>
5868:
5869: <li><p>Remove the <var title="">formatting element</var> from the
5870: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
5871: new element into the <a href="#list-of-active-formatting-elements">list of active formatting
5872: elements</a> at the position of the aforementioned
5873: bookmark.</p></li>
5874:
5875: <li><p>Remove the <var title="">formatting element</var> from the
5876: <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
5877: into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
5878: the position of the <var title="">furthest block</var> in that
5879: stack.</p></li>
5880:
5881: <li><p>Jump back to step 1 in this series of steps.</p></li>
5882:
1.334 mike 5883: </ol><p class="note">Because of the way this algorithm causes elements
1.304 mike 5884: to change parents, it has been dubbed the "adoption agency
5885: algorithm" (in contrast with other possible algorithms for dealing
5886: with misnested content, which included the "incest algorithm", the
1.1 mike 5887: "secret affair algorithm", and the "Heisenberg algorithm").</p>
5888:
5889: </dd>
5890:
5891: <dt>A start tag whose tag name is "button"</dt>
5892: <dd>
5893:
5894: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5895: an element in scope">has a <code>button</code> element in
5896: scope</a>, then this is a <a href="#parse-error">parse error</a>;
5897: act as if an end tag with the tag name "button" had been seen,
5898: then reprocess the token.</p>
5899:
5900: <p>Otherwise:</p>
5901:
5902: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5903: any.</p>
5904:
5905: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5906:
5907: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
5908: formatting elements</a>.</p>
5909:
5910: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5911:
5912: </dd>
5913:
5914: <dt>A start tag token whose tag name is one of: "applet",
5915: "marquee", "object"</dt>
5916: <dd>
5917:
5918: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5919: any.</p>
5920:
5921: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5922:
5923: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
5924: formatting elements</a>.</p>
5925:
5926: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5927:
5928: </dd>
5929:
5930: <dt>An end tag token whose tag name is one of: "applet", "button",
5931: "marquee", "object"</dt>
5932: <dd>
5933:
5934: <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>
5935: with the same tag name as that of the token, then this is a
5936: <a href="#parse-error">parse error</a>; ignore the token.</p>
5937:
5938: <p>Otherwise, run these steps:</p>
5939:
5940: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5941:
5942: <li><p>If the <a href="#current-node">current node</a> is not an element with
5943: the same tag name as that of the token, then this is a
5944: <a href="#parse-error">parse error</a>.</p></li>
5945:
5946: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5947: until an element with the same tag name as the token has been
5948: popped from the stack.</p></li>
5949:
5950: <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
5951: last marker</a>.</li>
5952:
5953: </ol></dd>
5954:
5955: <dt>A start tag whose tag name is "table"</dt>
5956: <dd>
5957:
5958: <p>If the <code>Document</code> is <em>not</em> set to
5959: <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
5960: elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
5961: <code>p</code> element in scope</a>, then act as if an end tag
5962: with the tag name "p" had been seen.</p> <!-- i hate myself (this
5963: quirk was basically caused by acid2; if i'd realised we could
5964: change the specs when i wrote acid2, we could have avoided having
5965: any parsing-mode quirks) -Hixie -->
5966:
5967: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5968:
5969: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5970:
5971: <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>
5972:
5973: </dd>
5974:
5975: <dt>A start tag whose tag name is one of: "area", "basefont",
1.589 mike 5976: "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1 mike 5977: <dd>
5978:
5979: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5980: any.</p>
5981:
5982: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5983: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
5984: elements</a>.</p>
5985:
5986: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
5987: token's <i>self-closing flag</i></a>, if it is set.</p>
5988:
5989: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589 mike 5990: shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1 mike 5991:
5992: </dd>
5993:
5994: <dt>A start tag whose tag name is one of: "param", "source"</dt>
5995: <dd>
5996:
5997: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5998: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
5999: elements</a>.</p>
6000:
6001: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6002: token's <i>self-closing flag</i></a>, if it is set.</p>
6003:
6004: </dd>
6005:
6006: <dt>A start tag whose tag name is "hr"</dt>
6007: <dd>
6008:
6009: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6010: an element in scope">has a <code>p</code> element in
6011: scope</a>, then act as if an end tag with the tag name
6012: "p" had been seen.</p>
6013:
6014: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6015: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6016: elements</a>.</p>
6017:
6018: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6019: token's <i>self-closing flag</i></a>, if it is set.</p>
6020:
6021: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6022:
6023: </dd>
6024:
6025: <dt>A start tag whose tag name is "image"</dt>
6026: <dd>
6027: <p><a href="#parse-error">Parse error</a>. Change the token's tag name
6028: to "img" and reprocess it. (Don't ask.)</p> <!-- As of
6029: 2005-12, studies showed that around 0.2% of pages used the
6030: <image> element. -->
6031: </dd>
6032:
6033: <dt id="isindex">A start tag whose tag name is "isindex"</dt>
6034: <dd>
6035:
6036: <p><a href="#parse-error">Parse error</a>.</p>
6037:
6038: <p>If the <a href="#form-element-pointer"><code title="">form</code> element
6039: pointer</a> is not null, then ignore the token.</p>
6040:
6041: <p>Otherwise:</p>
6042:
6043: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6044: token's <i>self-closing flag</i></a>, if it is set.</p> <!--
6045: purely to reduce the number of errors (we don't care if they
6046: included the /, they're not supposed to be including the tag at
6047: all! -->
6048:
6049: <p>Act as if a start tag token with the tag name "form" had been seen.</p>
6050:
6051: <p>If the token has an attribute called "action", set the
6052: <code title="attr-form-action">action</code> attribute on the
6053: resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
6054: "action" attribute of the token.</p>
6055:
6056: <p>Act as if a start tag token with the tag name "hr" had been
6057: seen.</p>
6058:
6059: <p>Act as if a start tag token with the tag name "label" had been
6060: seen.</p>
6061:
6062: <p>Act as if a stream of character tokens had been seen (see below
6063: for what they should say).</p>
6064:
6065: <p>Act as if a start tag token with the tag name "input" had been
6066: seen, with all the attributes from the "isindex" token except
6067: "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
6068: <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
6069:
6070: <p>Act as if a stream of character tokens had been seen (see
6071: below for what they should say).</p>
6072:
6073: <p>Act as if an end tag token with the tag name "label" had been
6074: seen.</p>
6075:
6076: <p>Act as if a start tag token with the tag name "hr" had been
6077: seen.</p>
6078:
6079: <p>Act as if an end tag token with the tag name "form" had been
6080: seen.</p>
6081:
6082: <p>If the token has an attribute with the name "prompt", then the
6083: first stream of characters must be the same string as given in
6084: that attribute, and the second stream of characters must be
6085: empty. Otherwise, the two streams of character tokens together
6086: should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
6087: equivalent of "This is a searchable index. Insert your search
6088: keywords here: (input field)" in the user's preferred
6089: language.</p>
6090:
6091: </dd>
6092:
6093: <dt>A start tag whose tag name is "textarea"</dt>
6094: <dd>
6095:
6096: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
6097: token.</p></li>
6098:
6099: <li><p>If the next token is a U+000A LINE FEED (LF) character
6100: token, then ignore that token and move on to the next
6101: one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
6102: ignored as an authoring convenience.)</p></li>
6103:
1.541 mike 6104: <li><p>Switch the tokenizer to the the <a href="#rcdata-state">RCDATA
6105: state</a>.</p></li>
1.1 mike 6106:
6107: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
6108: current <a href="#insertion-mode">insertion mode</a>.</p>
6109:
6110: </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
6111: ok".</p></li>
6112:
1.540 mike 6113: <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 6114:
6115: </ol></dd>
6116:
6117: <dt>A start tag whose tag name is "xmp"</dt>
6118: <dd>
6119:
1.233 mike 6120: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6121: an element in scope">has a <code>p</code> element in
6122: scope</a>, then act as if an end tag with the tag name
6123: "p" had been seen.</p>
6124:
1.1 mike 6125: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6126: any.</p>
6127:
6128: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6129:
1.91 mike 6130: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6131:
6132: </dd>
6133:
6134: <dt>A start tag whose tag name is "iframe"</dt>
6135: <dd>
6136:
6137: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6138:
1.91 mike 6139: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6140:
6141: </dd>
6142:
6143: <dt>A start tag whose tag name is "noembed"</dt>
6144: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
6145: <dd>
6146:
1.91 mike 6147: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6148:
6149: </dd>
6150:
6151: <dt>A start tag whose tag name is "select"</dt>
6152: <dd>
6153:
6154: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6155: any.</p>
6156:
6157: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6158:
6159: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6160:
6161: <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>",
6162: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6163: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
6164: row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
6165: cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
6166: "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
6167: table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
6168: to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
6169:
6170: </dd>
6171:
6172: <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
6173: <dd>
6174:
6175: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6176: element in scope">has an <code>option</code> element in
6177: scope</a>, then act as if an end tag with the tag name "option"
6178: had been seen.</p>
6179:
6180: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6181: any.</p>
6182:
6183: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6184:
6185: </dd>
6186:
6187: <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
6188: <dd>
6189:
6190: <!-- the parsing rules for ruby really don't match IE much at all,
6191: but in practice the markup used is very simple and so strict
6192: compatibility with IE isn't required. For example, as defined
6193: here we get very, very different behaviour than IE for
6194: pathological cases like:
6195:
6196: <ruby><ol><li><p>a<rt>b
6197: <ruby>a<rt>b<p>c
6198:
6199: But in practice most ruby markup falls into these cases:
6200:
6201: <ruby>a<rt>b</ruby>
6202: <ruby>a<rp>b<rt>c<rp>d</ruby>
6203: <ruby>a<rt>b</rt></ruby>
6204: <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
6205:
6206: -->
6207:
6208: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6209: element in scope">has a <code>ruby</code> element in scope</a>,
6210: then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
6211: node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
6212: <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
6213: node</a> up to the node immediately before the bottommost
6214: <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
6215: elements</a>.</p>
6216:
6217: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6218:
6219: </dd>
6220:
6221: <dt>An end tag whose tag name is "br"</dt>
6222: <dd>
6223: <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
6224: the tag name "br" had been seen. Ignore the end tag token.</p>
6225: </dd>
6226:
6227: <dt>A start tag whose tag name is "math"</dt>
6228: <dd>
6229:
6230: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6231: any.</p>
6232:
6233: <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
6234: fixes the case of MathML attributes that are not all
6235: lowercase.)</p>
6236:
6237: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6238: fixes the use of namespaced attributes, in particular XLink.)</p>
6239:
6240: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
6241: <a href="#mathml-namespace">MathML namespace</a>.</p>
6242:
6243: <!-- If we ever change the frameset-ok flag to an insertion mode,
6244: the following change would be implied, except we'd have to do it
6245: even in the face of a self-closed tag:
6246: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6247: -->
6248:
6249: <p>If the token has its <i>self-closing flag</i> set, pop the
6250: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6251: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6252: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6253:
6254: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6255: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6256: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6257: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6258: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6259: foreign content">in foreign content</a>".</p>
6260:
6261: </dd>
6262:
6263: <dt>A start tag whose tag name is "svg"</dt>
6264: <dd>
6265:
6266: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6267: any.</p>
6268:
6269: <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
6270: the case of SVG attributes that are not all lowercase.)</p>
6271:
6272: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6273: fixes the use of namespaced attributes, in particular XLink in
6274: SVG.)</p>
6275:
6276: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
6277: <a href="#svg-namespace">SVG namespace</a>.</p>
6278:
6279: <!-- If we ever change the frameset-ok flag to an insertion mode,
6280: the following change would be implied, except we'd have to do it
6281: even in the face of a self-closed tag:
6282: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6283: -->
6284:
6285: <p>If the token has its <i>self-closing flag</i> set, pop the
6286: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6287: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6288: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6289:
6290: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6291: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6292: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6293: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6294: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6295: foreign content">in foreign content</a>".</p>
6296:
6297: </dd>
6298:
6299: <dt>A start <!--or end--> tag whose tag name is one of: "caption",
6300: "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
6301: "thead", "tr"</dt>
6302: <!--<dt>An end tag whose tag name is one of: "area", "base",
6303: "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
6304: "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589 mike 6305: "noframes", "param", "script", "select", "source", "style",
6306: "table", "textarea", "title", "wbr"</dt>-->
1.1 mike 6307: <!--<dt>An end tag whose tag name is "noscript", if the
6308: <span>scripting flag</span> is enabled</dt>-->
6309: <dd>
6310: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6311: <!-- end tags are commented out because since they can never end
6312: up on the stack anyway, the default end tag clause will
6313: automatically handle them. we don't want to have text in the spec
6314: that is just an optimisation, as that detracts from the spec
6315: itself -->
6316: </dd>
6317:
6318: <dt>Any other start tag</dt>
6319: <dd>
6320:
6321: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6322: any.</p>
6323:
6324: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6325:
6326: <p class="note">This element will be a <a href="#phrasing">phrasing</a>
6327: element.</p>
6328:
6329: </dd>
6330:
6331: <dt>Any other end tag</dt>
6332: <dd>
6333:
6334: <p>Run the following steps:</p>
6335:
6336: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
6337: node</a> (the bottommost node of the stack).</p></li>
6338:
6339: <li><p>If <var title="">node</var> has the same tag name as
6340: the end tag token, then:</p>
6341:
6342: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6343:
6344: <li><p>If the tag name of the end tag token does not match
6345: the tag name of the <a href="#current-node">current node</a>, this is a
6346: <a href="#parse-error">parse error</a>.</p></li>
6347:
6348: <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
6349: to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
6350:
6351: </ol></li>
6352:
6353: <li><p>Otherwise, if <var title="">node</var> is in neither the
6354: <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
6355: category, then this is a <a href="#parse-error">parse error</a>; ignore the
6356: token, and abort these steps.</p></li>
6357:
6358: <li><p>Set <var title="">node</var> to the previous entry in the
6359: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
6360:
6361: <li><p>Return to step 2.</p></li>
6362:
6363: </ol></dd>
6364:
1.614 mike 6365: </dl><h5 id="parsing-main-incdata"><span class="secno">9.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 6366:
6367: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540 mike 6368: mode: text">text</a>", tokens must be handled as follows:</p>
1.1 mike 6369:
6370: <dl class="switch"><dt>A character token</dt>
6371: <dd>
6372:
6373: <p><a href="#insert-a-character" title="insert a character">Insert the token's
6374: character</a> into the <a href="#current-node">current node</a>.</p>
6375:
6376: </dd>
6377:
6378: <dt>An end-of-file token</dt>
6379: <dd>
6380:
6381: <!-- can't be the fragment case -->
6382: <p><a href="#parse-error">Parse error</a>.</p>
6383:
6384: <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484 mike 6385: element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
6386: started"</a>.</p>
1.1 mike 6387:
6388: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6389: elements</a>.</p>
6390:
6391: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6392: insertion mode</a> and reprocess the current token.</p>
6393:
6394: </dd>
6395:
6396: <dt>An end tag whose tag name is "script"</dt>
6397: <dd>
6398:
6399: <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
6400: (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
6401:
6402: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6403: elements</a>.</p>
6404:
6405: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6406: insertion mode</a>.</p>
6407:
6408: <p>Let the <var title="">old insertion point</var> have the
6409: same value as the current <a href="#insertion-point">insertion point</a>. Let
6410: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
6411: input character</a>.</p>
6412:
6413: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
6414: one.</p>
6415:
6416: <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 6417: which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1 mike 6418: to be inserted into the tokenizer</a>, and might cause the
6419: tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
6420:
6421: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
6422: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
6423: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6424:
6425: <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
6426: <a href="#insertion-point">insertion point</a> to its previous value. This value
6427: might be the "undefined" value.)</p>
6428:
6429: <p id="scriptTagParserResumes">At this stage, if there is a
1.484 mike 6430: <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1 mike 6431:
6432: <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
6433:
6434: <dd>
6435:
6436: <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
6437: processing of any nested invocations of the tokenizer, yielding
6438: control back to the caller. (Tokenization will resume when the
6439: caller returns to the "outer" tree construction stage.)</p>
6440:
6441: <p class="note">The tree construction stage of this particular
6442: parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159 mike 6443: 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 6444:
6445: </dd>
6446:
6447:
6448: <dt>Otherwise:</dt>
6449:
6450: <dd>
6451:
6452: <p>Follow these steps:</p>
6453:
1.484 mike 6454: <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
6455: parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
6456: parsing-blocking script</a>.</p></li>
6457:
6458: <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
6459: for this instance of the <a href="#html-parser">HTML parser</a>, such that
6460: the <a href="browsers.html#event-loop">event loop</a> will not run <a href="browsers.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a>.</p></li>
6461:
6462: <li><p><a href="browsers.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
6463: scripts</a> and <var title="">the script</var>'s
6464: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
6465:
6466: <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
6467: for this instance of the <a href="#html-parser">HTML parser</a>, such that
6468: <a href="browsers.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a> can again be
6469: run.</p></li>
1.1 mike 6470:
6471: <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
6472: <a href="#next-input-character">next input character</a>.</p></li>
6473:
6474: <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
6475: by one (it should be zero before this step, so this sets it to
6476: one).</p></li>
6477:
1.484 mike 6478: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
6479: <var title="">the script</var>.</p></li>
1.1 mike 6480:
6481: <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
6482: by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
6483: zero (which it always should be at this point), then set the
6484: <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6485:
6486: </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
6487: again.</p></li>
6488:
1.484 mike 6489: <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1 mike 6490: script</a>, then repeat these steps from step 1.</p></li>
6491:
6492: </ol></dd>
6493:
6494: </dl></dd>
6495:
6496: <dt>Any other end tag</dt>
6497: <dd>
6498:
6499: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6500: elements</a>.</p>
6501:
6502: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6503: insertion mode</a>.</p>
6504:
6505: </dd>
6506:
1.614 mike 6507: </dl><h5 id="parsing-main-intable"><span class="secno">9.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 6508:
6509: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
6510: mode: in table">in table</a>", tokens must be handled as follows:</p>
6511:
6512: <dl class="switch"><dt>A character token</dt>
6513: <dd>
6514:
6515: <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
6516: be an empty list of tokens.</p>
6517:
6518: <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
6519: <a href="#insertion-mode">insertion mode</a>.</p>
6520:
6521: <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
6522: reprocess the token.</p>
6523:
6524: </dd>
6525:
6526: <dt>A comment token</dt>
6527: <dd>
6528: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
6529: node</a> with the <code title="">data</code> attribute set to
6530: the data given in the comment token.</p>
6531: </dd>
6532:
6533: <dt>A DOCTYPE token</dt>
6534: <dd>
6535: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6536: </dd>
6537:
6538: <dt>A start tag whose tag name is "caption"</dt>
6539: <dd>
6540:
6541: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6542: below.)</p>
6543:
6544: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6545: formatting elements</a>.</p>
6546:
6547: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6548: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
6549:
6550: </dd>
6551:
6552: <dt>A start tag whose tag name is "colgroup"</dt>
6553: <dd>
6554:
6555: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6556: below.)</p>
6557:
6558: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6559: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
6560: group</a>".</p>
6561:
6562: </dd>
6563:
6564: <dt>A start tag whose tag name is "col"</dt>
6565: <dd>
6566: <p>Act as if a start tag token with the tag name "colgroup"
6567: had been seen, then reprocess the current token.</p>
6568: </dd>
6569:
6570: <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
6571: <dd>
6572:
6573: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6574: below.)</p>
6575:
6576: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6577: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6578: body</a>".</p>
6579:
6580: </dd>
6581:
6582: <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
6583: <dd>
6584: <p>Act as if a start tag token with the tag name "tbody" had
6585: been seen, then reprocess the current token.</p>
6586: </dd>
6587:
6588: <dt>A start tag whose tag name is "table"</dt>
6589: <dd>
6590:
6591: <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
6592: the tag name "table" had been seen, then, if that token wasn't
6593: ignored, reprocess the current token.</p>
6594:
6595: <p class="note">The fake end tag token here can only be
6596: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6597:
6598: </dd>
6599:
6600: <dt>An end tag whose tag name is "table"</dt>
6601: <dd>
6602:
6603: <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
6604: scope</a> with the same tag name as the token, this is a
6605: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6606: case</a>)</p>
6607:
6608: <p>Otherwise:</p>
6609:
6610: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
6611: element has been popped from the stack.</p>
6612:
6613: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
6614:
6615: </dd>
6616:
6617: <dt>An end tag whose tag name is one of: "body", "caption",
6618: "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
6619: "thead", "tr"</dt>
6620: <dd>
6621: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6622: </dd>
6623:
6624: <dt>A start tag whose tag name is one of: "style", "script"</dt>
6625: <dd>
6626:
6627: <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
6628: mode</a>.</p>
6629:
6630: </dd>
6631:
6632: <dt>A start tag whose tag name is "input"</dt>
6633: <dd>
6634:
6635: <p>If the token does not have an attribute with the name "type",
6636: or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
6637: case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
6638: else" entry below.</p>
6639:
6640: <p>Otherwise:</p>
6641:
6642: <p><a href="#parse-error">Parse error</a>.</p>
6643:
6644: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6645:
6646: <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
6647: open elements</a>.</p>
6648:
6649: </dd>
6650:
1.603 mike 6651: <dt>A start tag whose tag name is "form"</dt>
6652: <dd>
6653:
6654: <p><a href="#parse-error">Parse error</a>.</p>
6655:
6656: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6657:
1.637 mike 6658: <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 6659: open elements</a>.</p>
6660:
6661: </dd>
6662:
1.1 mike 6663: <dt>An end-of-file token</dt>
6664: <dd>
6665:
6666: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 6667: <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 6668: error</a>.</p>
6669:
6670: <p class="note">It can only be the <a href="#current-node">current node</a> in
6671: the <a href="#fragment-case">fragment case</a>.</p>
6672:
6673: <p><a href="#stop-parsing">Stop parsing</a>.</p>
6674:
6675: </dd>
6676:
6677: <dt>Anything else</dt>
6678: <dd>
6679:
6680: <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
6681: rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
6682: body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
6683: <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
6684: <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
6685: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
6686: into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
6687:
6688: </dd>
6689:
6690: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
6691: back to a table context</dfn>, it means that the UA must, while
6692: 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 6693: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 6694: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
6695:
6696: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 6697: <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 6698: case</a>.</p>
6699:
6700:
6701:
1.614 mike 6702: <h5 id="parsing-main-intabletext"><span class="secno">9.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 6703:
6704: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
6705: mode: in table text">in table text</a>", tokens must be handled
6706: as follows:</p>
6707:
6708: <dl class="switch"><dt>A character token</dt>
6709: <dd>
6710:
6711: <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
6712: tokens</a></var> list.</p>
6713:
6714: </dd>
6715:
6716:
6717: <dt>Anything else</dt>
6718: <dd>
6719:
6720: <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
6721: tokens</a></var> list are character tokens that are not one of U+0009
6722: CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
6723: (FF), <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE, then
6724: reprocess those character tokens using the rules given in the
6725: "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
6726: table">in table</a>" insertion mode.</p>
6727:
6728: <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
6729: characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
6730: tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
6731:
6732: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6733: insertion mode</a> and reprocess the token.</p>
6734:
6735: </dd>
6736:
1.614 mike 6737: </dl><h5 id="parsing-main-incaption"><span class="secno">9.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 6738:
6739: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
6740: mode: in caption">in caption</a>", tokens must be handled as follows:</p>
6741:
6742: <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
6743: <dd>
6744:
6745: <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
6746: scope</a> with the same tag name as the token, this is a
6747: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6748: case</a>)</p>
6749:
6750: <p>Otherwise:</p>
6751:
6752: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
6753:
6754: <p>Now, if the <a href="#current-node">current node</a> is not a
6755: <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
6756: error</a>.</p>
6757:
6758: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
6759: element has been popped from the stack.</p>
6760:
6761: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
6762: the last marker</a>.</p>
6763:
6764: <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>
6765:
6766: </dd>
6767:
6768: <dt>A start tag whose tag name is one of: "caption", "col",
6769: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
6770: <dt>An end tag whose tag name is "table"</dt>
6771: <dd>
6772:
6773: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
6774: name "caption" had been seen, then, if that token wasn't
6775: ignored, reprocess the current token.</p>
6776:
6777: <p class="note">The fake end tag token here can only be
6778: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6779:
6780: </dd>
6781:
6782: <dt>An end tag whose tag name is one of: "body", "col",
6783: "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
6784: "tr"</dt>
6785: <dd>
6786: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6787: </dd>
6788:
6789: <dt>Anything else</dt>
6790: <dd>
6791: <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
6792: mode</a>.</p>
6793: </dd>
6794:
1.614 mike 6795: </dl><h5 id="parsing-main-incolgroup"><span class="secno">9.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 6796:
6797: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
6798: mode: in column group">in column group</a>", tokens must be handled as follows:</p>
6799:
6800: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
6801: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
6802: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
6803: <dd>
6804: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
6805: the <a href="#current-node">current node</a>.</p>
6806: </dd>
6807:
6808: <dt>A comment token</dt>
6809: <dd>
6810: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
6811: node</a> with the <code title="">data</code> attribute set to
6812: the data given in the comment token.</p>
6813: </dd>
6814:
6815: <dt>A DOCTYPE token</dt>
6816: <dd>
6817: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6818: </dd>
6819:
6820: <dt>A start tag whose tag name is "html"</dt>
6821: <dd>
6822: <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
6823: mode</a>.</p>
6824: </dd>
6825:
6826: <dt>A start tag whose tag name is "col"</dt>
6827: <dd>
6828:
6829: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6830: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6831: elements</a>.</p>
6832:
6833: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6834: token's <i>self-closing flag</i></a>, if it is set.</p>
6835:
6836: </dd>
6837:
6838: <dt>An end tag whose tag name is "colgroup"</dt>
6839: <dd>
6840:
6841: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 6842: <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 6843: error</a>; ignore the token. (<a href="#fragment-case">fragment
6844: case</a>)</p>
6845:
6846: <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
6847: 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
6848: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
6849: "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
6850:
6851: </dd>
6852:
6853: <dt>An end tag whose tag name is "col"</dt>
6854: <dd>
6855: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6856: </dd>
6857:
6858: <dt>An end-of-file token</dt>
6859: <dd>
6860:
1.159 mike 6861: <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 6862: element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
6863: case</a>)</p>
6864:
6865: <p>Otherwise, act as described in the "anything else" entry
6866: below.</p>
6867:
6868: </dd>
6869:
6870: <dt>Anything else</dt>
6871: <dd>
6872:
6873: <p>Act as if an end tag with the tag name "colgroup" had been
6874: seen, and then, if that token wasn't ignored, reprocess the
6875: current token.</p>
6876:
6877: <p class="note">The fake end tag token here can only be
6878: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6879:
6880: </dd>
6881:
1.614 mike 6882: </dl><h5 id="parsing-main-intbody"><span class="secno">9.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 6883:
6884: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
6885: mode: in table body">in table body</a>", tokens must be handled as follows:</p>
6886:
6887: <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
6888: <dd>
6889:
6890: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
6891: context</a>. (See below.)</p>
6892:
6893: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
6894: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
6895: in row">in row</a>".</p>
6896:
6897: </dd>
6898:
6899: <dt>A start tag whose tag name is one of: "th", "td"</dt>
6900: <dd>
6901: <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
6902: the tag name "tr" had been seen, then reprocess the current
6903: token.</p>
6904: </dd>
6905:
6906: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
6907: "thead"</dt>
6908: <dd>
6909:
6910: <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
6911: scope</a> with the same tag name as the token, this is a
6912: <a href="#parse-error">parse error</a>. Ignore the token.</p>
6913:
6914: <p>Otherwise:</p>
6915:
6916: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
6917: context</a>. (See below.)</p>
6918:
6919: <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
6920: open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
6921: to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
6922:
6923: </dd>
6924:
6925: <dt>A start tag whose tag name is one of: "caption", "col",
6926: "colgroup", "tbody", "tfoot", "thead"</dt>
6927: <dt>An end tag whose tag name is "table"</dt>
6928: <dd>
6929:
6930: <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
6931: <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
6932: element in table scope</a>, this is a <a href="#parse-error">parse
6933: error</a>. Ignore the token. (<a href="#fragment-case">fragment
6934: case</a>)</p>
6935:
6936: <p>Otherwise:</p>
6937:
6938: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
6939: context</a>. (See below.)</p>
6940:
6941: <p>Act as if an end tag with the same tag name as the
6942: <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
6943: been seen, then reprocess the current token.</p>
6944:
6945: </dd>
6946:
6947: <dt>An end tag whose tag name is one of: "body", "caption",
6948: "col", "colgroup", "html", "td", "th", "tr"</dt>
6949: <dd>
6950: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6951: </dd>
6952:
6953: <dt>Anything else</dt>
6954: <dd>
6955: <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
6956: mode</a>.</p>
6957: </dd>
6958:
6959: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
6960: back to a table body context</dfn>, it means that the UA must,
6961: 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 6962: <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 6963: element, pop elements from the <a href="#stack-of-open-elements">stack of open
6964: elements</a>.</p>
6965:
6966: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 6967: <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 6968: case</a>.</p>
6969:
6970:
1.614 mike 6971: <h5 id="parsing-main-intr"><span class="secno">9.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 6972:
6973: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
6974: mode: in row">in row</a>", tokens must be handled as follows:</p>
6975:
6976: <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
6977: <dd>
6978:
6979: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
6980: context</a>. (See below.)</p>
6981:
6982: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
6983: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
6984: in cell">in cell</a>".</p>
6985:
6986: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6987: formatting elements</a>.</p>
6988:
6989: </dd>
6990:
6991: <dt>An end tag whose tag name is "tr"</dt>
6992: <dd>
6993:
6994: <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
6995: scope</a> with the same tag name as the token, this is a
6996: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6997: case</a>)</p>
6998:
6999: <p>Otherwise:</p>
7000:
7001: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7002: context</a>. (See below.)</p>
7003:
7004: <p>Pop the <a href="#current-node">current node</a> (which will be a
7005: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
7006: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
7007: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
7008: body</a>".</p>
7009:
7010: </dd>
7011:
7012: <dt>A start tag whose tag name is one of: "caption", "col",
7013: "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
7014: <dt>An end tag whose tag name is "table"</dt>
7015: <dd>
7016:
7017: <p>Act as if an end tag with the tag name "tr" had been seen,
7018: then, if that token wasn't ignored, reprocess the current
7019: token.</p>
7020:
7021: <p class="note">The fake end tag token here can only be
7022: ignored in the <a href="#fragment-case">fragment case</a>.</p>
7023:
7024: </dd>
7025:
7026: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
7027: "thead"</dt>
7028: <dd>
7029:
7030: <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
7031: scope</a> with the same tag name as the token, this is a
7032: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7033:
7034: <p>Otherwise, act as if an end tag with the tag name "tr" had
7035: been seen, then reprocess the current token.</p>
7036:
7037: </dd>
7038:
7039: <dt>An end tag whose tag name is one of: "body", "caption",
7040: "col", "colgroup", "html", "td", "th"</dt>
7041: <dd>
7042: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7043: </dd>
7044:
7045: <dt>Anything else</dt>
7046: <dd>
7047: <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
7048: mode</a>.</p>
7049: </dd>
7050:
7051: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
7052: back to a table row context</dfn>, it means that the UA must,
7053: 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 7054: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 7055: <a href="#stack-of-open-elements">stack of open 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.614 mike 7062: <h5 id="parsing-main-intd"><span class="secno">9.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 7063:
7064: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
7065: mode: in cell">in cell</a>", tokens must be handled as follows:</p>
7066:
7067: <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
7068: <dd>
7069:
7070: <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
7071: scope</a> with the same tag name as that of the token, then
7072: this is a <a href="#parse-error">parse error</a> and the token must be
7073: ignored.</p>
7074:
7075: <p>Otherwise:</p>
7076:
7077: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
7078:
7079: <p>Now, if the <a href="#current-node">current node</a> is not an element
7080: with the same tag name as the token, then this is a
7081: <a href="#parse-error">parse error</a>.</p>
7082:
7083: <p>Pop elements from this stack until an element with the same
7084: tag name as the token has been popped from the stack.</p>
7085:
7086: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
7087: the last marker</a>.</p>
7088:
7089: <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
7090: <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
7091: this point.)</p>
7092:
7093: </dd>
7094:
7095: <dt>A start tag whose tag name is one of: "caption", "col",
7096: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
7097: <dd>
7098:
7099: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
7100: <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
7101: a <code>td</code> or <code>th</code> element in table
7102: scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
7103: the token. (<a href="#fragment-case">fragment case</a>)</p>
7104:
7105: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7106: reprocess the current token.</p>
7107:
7108: </dd>
7109:
7110: <dt>An end tag whose tag name is one of: "body", "caption",
7111: "col", "colgroup", "html"</dt>
7112: <dd>
7113: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7114: </dd>
7115:
7116: <dt>An end tag whose tag name is one of: "table", "tbody",
7117: "tfoot", "thead", "tr"</dt>
7118: <dd>
7119:
7120: <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
7121: scope</a> with the same tag name as that of the token
7122: (which can only happen for "tbody", "tfoot" and "thead", or,
7123: in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
7124: error</a> and the token must be ignored.</p>
7125:
7126: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7127: reprocess the current token.</p>
7128:
7129: </dd>
7130:
7131: <dt>Anything else</dt>
7132: <dd>
7133: <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
7134: mode</a>.</p>
7135: </dd>
7136:
7137: </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
7138: mean to run the following algorithm:</p>
7139:
7140: <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>
7141: element in table scope</a>, then act as if an end tag token
7142: with the tag name "td" had been seen.</p></li>
7143:
7144: <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
7145: <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
7146: <code>th</code> element in table scope</a>; act as if an end
7147: tag token with the tag name "th" had been seen.</p></li>
7148:
7149: </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
7150: 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
7151: the same time, nor can it have neither when the <a href="#insertion-mode">insertion
7152: mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
7153: cell</a>".</p>
7154:
7155:
1.614 mike 7156: <h5 id="parsing-main-inselect"><span class="secno">9.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 7157:
7158: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
7159: mode: in select">in select</a>", tokens must be handled as follows:</p>
7160:
7161: <dl class="switch"><dt>A character token</dt>
7162: <dd>
7163: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7164: character</a> into the <a href="#current-node">current node</a>.</p>
7165: </dd>
7166:
7167: <dt>A comment token</dt>
7168: <dd>
7169: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7170: node</a> with the <code title="">data</code> attribute set to
7171: the data given in the comment token.</p>
7172: </dd>
7173:
7174: <dt>A DOCTYPE token</dt>
7175: <dd>
7176: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7177: </dd>
7178:
7179: <dt>A start tag whose tag name is "html"</dt>
7180: <dd>
7181: <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
7182: mode</a>.</p>
7183: </dd>
7184:
7185: <dt>A start tag whose tag name is "option"</dt>
7186: <dd>
7187:
7188: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7189: element, act as if an end tag with the tag name "option" had
7190: been seen.</p>
7191:
7192: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7193:
7194: </dd>
7195:
7196: <dt>A start tag whose tag name is "optgroup"</dt>
7197: <dd>
7198:
7199: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7200: element, act as if an end tag with the tag name "option" had
7201: been seen.</p>
7202:
7203: <p>If the <a href="#current-node">current node</a> is an
7204: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
7205: tag name "optgroup" had been seen.</p>
7206:
7207: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7208:
7209: </dd>
7210:
7211: <dt>An end tag whose tag name is "optgroup"</dt>
7212: <dd>
7213:
7214: <p>First, if the <a href="#current-node">current node</a> is an
7215: <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
7216: it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
7217: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
7218: the tag name "option" had been seen.</p>
7219:
7220: <p>If the <a href="#current-node">current node</a> is an
7221: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
7222: <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
7223: <a href="#parse-error">parse error</a>; ignore the token.</p>
7224:
7225: </dd>
7226:
7227: <dt>An end tag whose tag name is "option"</dt>
7228: <dd>
7229:
7230: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7231: element, then pop that node from the <a href="#stack-of-open-elements">stack of open
7232: elements</a>. Otherwise, this is a <a href="#parse-error">parse
7233: error</a>; ignore the token.</p>
7234:
7235: </dd>
7236:
7237: <dt>An end tag whose tag name is "select"</dt>
7238: <dd>
7239:
7240: <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
7241: scope</a> with the same tag name as the token, this is a
7242: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7243: case</a>)</p>
7244:
7245: <p>Otherwise:</p>
7246:
7247: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
7248: until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
7249: stack.</p>
7250:
7251: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
7252:
7253: </dd>
7254:
7255: <dt>A start tag whose tag name is "select"</dt>
7256: <dd>
7257:
7258: <p><a href="#parse-error">Parse error</a>. Act as if the token had been
7259: an end tag with the tag name "select" instead.</p>
7260:
7261: </dd>
7262:
7263: <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
7264: <dd>
1.73 mike 7265:
7266: <p><a href="#parse-error">Parse error</a>.</p>
7267:
1.124 mike 7268: <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>
7269: element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
7270: case</a>)</p>
1.73 mike 7271:
7272: <p>Otherwise, act as if an end tag with the tag name "select" had
7273: been seen, and reprocess the token.</p>
7274:
1.1 mike 7275: </dd>
7276:
7277: <dt>A start tag token whose tag name is "script"</dt>
7278: <dd>
7279: <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
7280: mode</a>.</p>
7281: </dd>
7282:
7283: <dt>An end-of-file token</dt>
7284: <dd>
7285:
7286: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7287: <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 7288: error</a>.</p>
7289:
7290: <p class="note">It can only be the <a href="#current-node">current node</a> in
7291: the <a href="#fragment-case">fragment case</a>.</p>
7292:
7293: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7294:
7295: </dd>
7296:
7297: <dt>Anything else</dt>
7298: <dd>
7299: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7300: </dd>
7301:
1.614 mike 7302: </dl><h5 id="parsing-main-inselectintable"><span class="secno">9.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 7303:
7304: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
7305: mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
7306:
7307: <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
7308: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7309: <dd>
7310: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
7311: name "select" had been seen, and reprocess the token.</p>
7312: </dd>
7313:
7314: <dt>An end tag whose tag name is one of: "caption", "table",
7315: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7316: <dd>
7317:
7318: <p><a href="#parse-error">Parse error</a>.</p>
7319:
7320: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
7321: element in table scope</a> with the same tag name as that
7322: of the token, then act as if an end tag with the tag name
7323: "select" had been seen, and reprocess the token. Otherwise,
7324: ignore the token.</p>
7325:
7326: </dd>
7327:
7328: <dt>Anything else</dt>
7329: <dd>
7330: <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
7331: mode</a>.</p>
7332: </dd>
7333:
1.614 mike 7334: </dl><h5 id="parsing-main-inforeign"><span class="secno">9.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 7335:
7336: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
7337: mode: in foreign content">in foreign content</a>", tokens must be
7338: handled as follows:</p>
7339:
7340: <dl class="switch"><dt>A character token</dt>
7341: <dd>
7342:
7343: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7344: character</a> into the <a href="#current-node">current node</a>.</p>
7345:
7346: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
7347: LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
7348: (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
7349: flag</a> to "not ok".</p>
7350:
7351: </dd>
7352:
7353: <dt>A comment token</dt>
7354: <dd>
7355: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7356: node</a> with the <code title="">data</code> attribute set to
7357: the data given in the comment token.</p>
7358: </dd>
7359:
7360: <dt>A DOCTYPE token</dt>
7361: <dd>
7362: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7363: </dd>
7364:
7365: <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="#svg-namespace">SVG namespace</a>.</dt>
7366: <dd>
7367:
7368: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7369: elements</a>.</p>
7370:
7371: <p>Let the <var title="">old insertion point</var> have the
7372: same value as the current <a href="#insertion-point">insertion point</a>. Let
7373: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
7374: input character</a>.</p>
7375:
7376: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
7377: one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
7378:
7379: <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
7380: the <code title="">script</code> element</a> according to the SVG
1.187 mike 7381: rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1 mike 7382:
1.159 mike 7383: <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 7384: tokenizer</a>, the parser will not be executed reentrantly,
7385: since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
7386:
7387: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
7388: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
7389: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
7390:
7391: <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
7392: <a href="#insertion-point">insertion point</a> to its previous value. This value
7393: might be the "undefined" value.)</p>
7394:
7395: </dd>
7396:
7397: <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="#mathml-namespace">MathML namespace</a>.</dt>
7398: <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="#mathml-namespace">MathML namespace</a>.</dt>
7399: <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="#mathml-namespace">MathML namespace</a>.</dt>
7400: <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="#mathml-namespace">MathML namespace</a>.</dt>
7401: <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="#mathml-namespace">MathML namespace</a>.</dt>
7402: <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="#mathml-namespace">MathML namespace</a>.</dt>
7403: <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">foreignObject</code> element in the <a href="#svg-namespace">SVG namespace</a>.</dt>
7404: <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">desc</code> element in the <a href="#svg-namespace">SVG namespace</a>.</dt>
7405: <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">title</code> element in the <a href="#svg-namespace">SVG namespace</a>.</dt>
7406: <dt>A start tag, if the <a href="#current-node">current node</a> is an element in the <a href="#html-namespace-0">HTML namespace</a>.</dt>
7407: <dt>An end tag</dt>
7408: <dd>
7409:
7410: <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
7411: <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7412:
7413: <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
7414: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336 mike 7415: content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
7416: element in scope">in scope</a> that has a namespace other than
7417: the <a href="#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1 mike 7418: mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7419:
7420: </dd>
7421:
7422: <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
7423: "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422 mike 7424: "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
7425: uniformly throughout the parser -->, "em", "embed", "h1", "h2",
7426: "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1 mike 7427: completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
7428: "li", "listing"<!-- so that pre and listing can be handled
7429: uniformly throughout the parser -->, "menu", "meta", "nobr",
7430: "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
7431: the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
7432: "span", "strong", "strike"<!-- so that s and strike can be handled
7433: uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305 mike 7434: "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
7435: list was determined empirically by studying over 6,000,000,000
1.422 mike 7436: pages that were specifically not XML pages -->
7437: <dt>A start tag whose tag name is "font", if the token has any
7438: attributes named "color", "face", or "size"</dt> <!-- the
7439: attributes here are required so that SVG <font> will go through as
7440: SVG but legacy <font>s won't -->
7441: <dt>An end-of-file token</dt> <dd>
1.1 mike 7442:
7443: <p><a href="#parse-error">Parse error</a>.</p>
7444:
7445: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
7446: the <a href="#current-node">current node</a> is in the <a href="#html-namespace-0">HTML
7447: namespace</a>.</p>
7448:
7449: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#secondary-insertion-mode">secondary
7450: insertion mode</a>, and reprocess the token.</p>
7451:
7452: </dd>
7453:
7454: <dt>Any other start tag</dt>
7455: <dd>
7456:
7457: <p>If the <a href="#current-node">current node</a> is an element in the
7458: <a href="#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
7459: attributes</a> for the token. (This fixes the case of MathML
7460: attributes that are not all lowercase.)</p>
7461:
7462: <p>If the <a href="#current-node">current node</a> is an element in the <a href="#svg-namespace">SVG
7463: namespace</a>, and the token's tag name is one of the ones in
7464: the first column of the following table, change the tag name to
7465: the name given in the corresponding cell in the second
7466: column. (This fixes the case of SVG elements that are not all
7467: lowercase.)</p>
7468:
7469: <table><thead><tr><th> Tag name </th><th> Element name
7470: </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
7471: </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
7472: </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
7473: </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
7474: </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
7475: </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
7476: </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
7477: </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
7478: </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
7479: </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
7480: </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
7481: </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
7482: </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
7483: </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
7484: </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
7485: </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
7486: </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
7487: </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
7488: </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
7489: </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
7490: </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
7491: </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
7492: </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
7493: </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
7494: </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
7495: </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
7496: </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
7497: </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
7498: </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
7499: </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
7500: </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
7501: </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
7502: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
7503: </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
7504: </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
7505: <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
7506: </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
7507: </td></tr></tbody></table><p>If the <a href="#current-node">current node</a> is an element in the <a href="#svg-namespace">SVG
7508: namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
7509: token. (This fixes the case of SVG attributes that are not all
7510: lowercase.)</p>
7511:
7512: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
7513: fixes the use of namespaced attributes, in particular XLink in
7514: SVG.)</p>
7515:
7516: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
7517: same namespace as the <a href="#current-node">current node</a>.</p>
7518:
7519: <p>If the token has its <i>self-closing flag</i> set, pop the
7520: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7521: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
7522: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
7523:
7524: </dd>
7525:
1.614 mike 7526: </dl><h5 id="parsing-main-afterbody"><span class="secno">9.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 7527:
7528: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
7529: mode: after body">after body</a>", tokens must be handled as follows:</p>
7530:
7531: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7532: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7533: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7534: <dd>
7535: <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
7536: mode</a>.</p>
7537: </dd>
7538:
7539: <dt>A comment token</dt>
7540: <dd>
7541: <p>Append a <code>Comment</code> node to the first element in
1.159 mike 7542: 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 7543: element), with the <code title="">data</code> attribute set to
7544: the data given in the comment token.</p>
7545: </dd>
7546:
7547: <dt>A DOCTYPE token</dt>
7548: <dd>
7549: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7550: </dd>
7551:
7552: <dt>A start tag whose tag name is "html"</dt>
7553: <dd>
7554: <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
7555: mode</a>.</p>
7556: </dd>
7557:
7558: <dt>An end tag whose tag name is "html"</dt>
7559: <dd>
7560:
7561: <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
7562: fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
7563: error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
7564:
7565: <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
7566: body</a>".</p>
7567:
7568: </dd>
7569:
7570: <dt>An end-of-file token</dt>
7571: <dd>
7572: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7573: </dd>
7574:
7575: <dt>Anything else</dt>
7576: <dd>
7577:
7578: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
7579: mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
7580: body</a>" and reprocess the token.</p>
7581:
7582: </dd>
7583:
1.614 mike 7584: </dl><h5 id="parsing-main-inframeset"><span class="secno">9.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 7585:
7586: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
7587: mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
7588:
7589: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7590: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7591: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7592: <dd>
7593: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7594: the <a href="#current-node">current node</a>.</p>
7595: </dd>
7596:
7597: <dt>A comment token</dt>
7598: <dd>
7599: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7600: node</a> with the <code title="">data</code> attribute set to
7601: the data given in the comment token.</p>
7602: </dd>
7603:
7604: <dt>A DOCTYPE token</dt>
7605: <dd>
7606: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7607: </dd>
7608:
7609: <dt>A start tag whose tag name is "html"</dt>
7610: <dd>
7611: <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
7612: mode</a>.</p>
7613: </dd>
7614:
7615: <dt>A start tag whose tag name is "frameset"</dt>
7616: <dd>
7617: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7618: </dd>
7619:
7620: <dt>An end tag whose tag name is "frameset"</dt>
7621: <dd>
7622:
7623: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 7624: <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 7625: error</a>; ignore the token. (<a href="#fragment-case">fragment
7626: case</a>)</p>
7627:
7628: <p>Otherwise, pop the <a href="#current-node">current node</a> from the
7629: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7630:
7631: <p>If the parser was <em>not</em> originally created as part
7632: of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
7633: (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5 mike 7634: node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1 mike 7635: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
7636: frameset</a>".</p>
7637:
7638: </dd>
7639:
7640: <dt>A start tag whose tag name is "frame"</dt>
7641: <dd>
7642:
7643: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
7644: Immediately pop the <a href="#current-node">current node</a> off the
7645: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7646:
7647: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
7648: token's <i>self-closing flag</i></a>, if it is set.</p>
7649:
7650: </dd>
7651:
7652: <dt>A start tag whose tag name is "noframes"</dt>
7653: <dd>
7654: <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
7655: mode</a>.</p>
7656: </dd>
7657:
7658: <dt>An end-of-file token</dt>
7659: <dd>
7660:
7661: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7662: <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 7663: error</a>.</p>
7664:
7665: <p class="note">It can only be the <a href="#current-node">current node</a> in
7666: the <a href="#fragment-case">fragment case</a>.</p>
7667:
7668: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7669:
7670: </dd>
7671:
7672: <dt>Anything else</dt>
7673: <dd>
7674: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7675: </dd>
7676:
1.614 mike 7677: </dl><h5 id="parsing-main-afterframeset"><span class="secno">9.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 7678:
7679: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
7680: mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
7681:
7682: <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
7683: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7684: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7685: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7686: <dd>
7687: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7688: the <a href="#current-node">current node</a>.</p>
7689: </dd>
7690:
7691: <dt>A comment token</dt>
7692: <dd>
7693: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7694: node</a> with the <code title="">data</code> attribute set to
7695: the data given in the comment token.</p>
7696: </dd>
7697:
7698: <dt>A DOCTYPE token</dt>
7699: <dd>
7700: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7701: </dd>
7702:
7703: <dt>A start tag whose tag name is "html"</dt>
7704: <dd>
7705: <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
7706: mode</a>.</p>
7707: </dd>
7708:
7709: <dt>An end tag whose tag name is "html"</dt>
7710: <dd>
7711: <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
7712: frameset</a>".</p>
7713: </dd>
7714:
7715: <dt>A start tag whose tag name is "noframes"</dt>
7716: <dd>
7717: <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
7718: mode</a>.</p>
7719: </dd>
7720:
7721: <dt>An end-of-file token</dt>
7722: <dd>
7723: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7724: </dd>
7725:
7726: <dt>Anything else</dt>
7727: <dd>
7728: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7729: </dd>
7730:
1.614 mike 7731: </dl><h5 id="the-after-after-body-insertion-mode"><span class="secno">9.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 7732:
7733: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
7734: mode: after after body">after after body</a>", tokens must be handled as follows:</p>
7735:
7736: <dl class="switch"><dt>A comment token</dt>
7737: <dd>
7738: <p>Append a <code>Comment</code> node to the <code>Document</code>
7739: object with the <code title="">data</code> attribute set to the
7740: data given in the comment token.</p>
7741: </dd>
7742:
7743: <dt>A DOCTYPE token</dt>
7744: <dt>A character token that is one of U+0009 CHARACTER
7745: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7746: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7747: <dt>A start tag whose tag name is "html"</dt>
7748: <dd>
7749: <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
7750: mode</a>.</p>
7751: </dd>
7752:
7753: <dt>An end-of-file token</dt>
7754: <dd>
7755: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7756: </dd>
7757:
7758: <dt>Anything else</dt>
7759: <dd>
7760: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7761: to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
7762: reprocess the token.</p>
7763: </dd>
7764:
1.614 mike 7765: </dl><h5 id="the-after-after-frameset-insertion-mode"><span class="secno">9.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 7766:
7767: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
7768: mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
7769:
7770: <dl class="switch"><dt>A comment token</dt>
7771: <dd>
7772: <p>Append a <code>Comment</code> node to the <code>Document</code>
7773: object with the <code title="">data</code> attribute set to the
7774: data given in the comment token.</p>
7775: </dd>
7776:
7777: <dt>A DOCTYPE token</dt>
7778: <dt>A character token that is one of U+0009 CHARACTER
7779: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7780: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7781: <dt>A start tag whose tag name is "html"</dt>
7782: <dd>
7783: <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
7784: mode</a>.</p>
7785: </dd>
7786:
7787: <dt>An end-of-file token</dt>
7788: <dd>
7789: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7790: </dd>
7791:
7792: <dt>A start tag whose tag name is "noframes"</dt>
7793: <dd>
7794: <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
7795: mode</a>.</p>
7796: </dd>
7797:
7798: <dt>Anything else</dt>
7799: <dd>
7800: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7801: </dd>
7802:
1.266 mike 7803: </dl></div><div class="impl">
7804:
1.614 mike 7805: <h4 id="the-end"><span class="secno">9.2.6 </span>The end</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 7806:
7807: <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484 mike 7808: the document, the user agent must run the following steps:</p>
1.1 mike 7809:
1.484 mike 7810: <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
7811: "interactive" <!-- this also synchronously fires an event --> and
7812: the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
7813:
7814: <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
7815: document has finished parsing</a> is not empty, run these
7816: substeps:</p>
7817:
7818: <ol><li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until the first
7819: <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
7820: execute when the document has finished parsing</a> has its
7821: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
7822: is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
7823: blocking scripts</a>.</p></li>
7824:
7825: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
7826: 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
7827: execute when the document has finished parsing</a>.</p></li>
7828:
7829: <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
7830: <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
7831: finished parsing</a> (i.e. shift out the first entry in the
7832: list).</p></li>
7833:
7834: <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
7835: document has finished parsing</a> is still not empty, repeat
7836: these substeps again from substep 1.</p>
7837:
7838: </li></ol></li>
7839:
7840: <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until the the <a href="semantics.html#list-of-scripts-that-will-execute-as-soon-as-possible">list of
7841: scripts that will execute as soon as possible</a> is
7842: empty.</p></li>
7843:
7844: <li><p><a href="browsers.html#queue-a-task">Queue a task</a> to <a href="browsers.html#fire-a-simple-event">fire a simple
7845: event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
7846: <code>Document</code>.</p></li>
7847:
7848: <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
7849: <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
7850: the <code>Document</code>.</p></li>
7851:
7852: <li><p><a href="browsers.html#queue-a-task">Queue a task</a> to set the <a href="dom.html#current-document-readiness">current document
7853: readiness</a> to "complete". <!-- this also fires an event
7854: synchronously during the task --></p></li>
1.1 mike 7855:
1.484 mike 7856: <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
1.1 mike 7857: context</a>, then <a href="browsers.html#queue-a-task">queue a task</a> to <a href="browsers.html#fire-a-simple-event">fire a
1.460 mike 7858: simple event</a> named <code title="event-load">load</code> at
1.1 mike 7859: the <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
7860: its <code title="dom-event-target">target</code> set to the
7861: <code>Document</code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
1.484 mike 7862: <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1 mike 7863:
1.569 mike 7864: <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
7865: context</a>, then <a href="browsers.html#queue-a-task">queue a task</a> to <a href="browsers.html#fire-a-simple-event">fire a
7866: simple event</a> named <code title="event-pageshow">pageshow</code> at the
7867: <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object.</p></li>
7868:
1.484 mike 7869: <li><p>If the <code>Document</code> has a <a href="history.html#pending-state-object">pending state
1.1 mike 7870: object</a>, then <a href="browsers.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 in no namespace on the
7871: <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object using the
7872: <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
7873: current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484 mike 7874: must bubble but not be cancelable and has no default
7875: action.</p></li>
1.1 mike 7876:
1.484 mike 7877: </ol><p>The <a href="browsers.html#task-source">task source</a> for the <a href="browsers.html#concept-task" title="concept-task">tasks</a> mentioned in this section is the
7878: <a href="browsers.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1 mike 7879:
1.266 mike 7880: </div><div class="impl">
1.1 mike 7881:
1.614 mike 7882: <h4 id="coercing-an-html-dom-into-an-infoset"><span class="secno">9.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 7883:
7884: <p>When an application uses an <a href="#html-parser">HTML parser</a> in
7885: conjunction with an XML pipeline, it is possible that the
7886: constructed DOM is not compatible with the XML tool chain in certain
7887: subtle ways. For example, an XML toolchain might not be able to
7888: represent attributes with the name <code title="">xmlns</code>,
7889: since they conflict with the Namespaces in XML syntax. There is also
7890: some data that the <a href="#html-parser">HTML parser</a> generates that isn't
7891: included in the DOM itself. This section specifies some rules for
7892: handling these issues.</p>
7893:
7894: <p>If the XML API being used doesn't support DOCTYPEs, the tool may
7895: drop DOCTYPEs altogether.</p>
7896:
7897: <p>If the XML API doesn't support attributes in no namespace that
7898: are named "<code title="">xmlns</code>", attributes whose names
7899: start with "<code title="">xmlns:</code>", or attributes in the
7900: <a href="#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
7901: attributes.</p>
7902:
7903: <p>The tool may annotate the output with any namespace declarations
7904: required for proper operation.</p>
7905:
7906: <p>If the XML API being used restricts the allowable characters in
7907: the local names of elements and attributes, then the tool may map
7908: all element and attribute local names that the API wouldn't support
7909: to a set of names that <em>are</em> allowed, by replacing any
7910: character that isn't supported with the uppercase letter U and the
7911: six digits of the character's Unicode code point when expressed in
7912: hexadecimal, using digits 0-9 and capital letters A-F as the
7913: symbols, in increasing numeric order.</p>
7914:
7915: <p class="example">For example, the element name <code title="">foo<bar</code>, which can be output by the <a href="#html-parser">HTML
7916: parser</a>, though it is neither a legal HTML element name nor a
7917: well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
7918: element name (though it's still not legal in HTML by any means).</p>
7919:
7920: <p class="example">As another example, consider the attribute
7921: <code>xlink:href</code>. Used on a MathML element, it becomes, after
7922: being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
7923: attribute with a prefix "<code title="">xlink</code>" and a local
7924: name "<code title="">href</code>". However, used on an HTML element,
7925: it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
7926: might not be accepted by an XML API. It could thus get converted,
7927: becoming "<code title="">xlinkU00003Ahref</code>".</p>
7928:
7929: <p class="note">The resulting names from this conversion
7930: conveniently can't clash with any attribute generated by the
7931: <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
7932: those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
7933: algorithm's table.</p>
7934:
7935: <p>If the XML API restricts comments from having two consecutive
7936: U+002D HYPHEN-MINUS characters (--), the tool may insert a single
7937: U+0020 SPACE character between any such offending characters.</p>
7938:
7939: <p>If the XML API restricts comments from ending in a
7940: U+002D HYPHEN-MINUS character (-), the tool may insert a single
7941: U+0020 SPACE character at the end of such comments.</p>
7942:
7943: <p>If the XML API restricts allowed characters in character data,
1.439 mike 7944: attribute values, or comments, the tool may replace any U+000C FORM
7945: FEED (FF) character with a U+0020 SPACE character, and any other
7946: literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1 mike 7947:
7948: <p>If the tool has no way to convey out-of-band information, then
7949: the tool may drop the following information:</p>
7950:
7951: <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no quirks mode</a></i>,
7952: <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>
7953:
7954: <li>The association between form controls and forms that aren't
7955: their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
7956: <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
7957:
7958: </ul><p class="note">The mutations allowed by this section apply
7959: <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
7960: applied. For example, a <code title=""><a::></code> start tag
7961: will be closed by a <code title=""></a::></code> end tag, and
7962: never by a <code title=""></aU00003AU00003A></code> end tag, even
7963: if the user agent is using the rules above to then generate an
7964: actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
7965:
1.266 mike 7966: </div><div class="impl">
1.1 mike 7967:
1.614 mike 7968: <h4 id="an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">9.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 7969:
7970: <p><i>This section is non-normative.</i></p>
7971:
7972: <p>This section examines some erroneous markup and discusses how
7973: the <a href="#html-parser">HTML parser</a> handles these cases.</p>
7974:
7975:
7976: <h5 id="misnested-tags:-b-i-b-i"><span class="secno">9.2.8.1 </span>Misnested tags: <b><i></b></i></h5>
7977:
7978: <p><i>This section is non-normative.</i></p>
7979:
7980: <p>The most-often discussed example of erroneous markup is as
7981: follows:</p>
7982:
7983: <pre><p>1<b>2<i>3</b>4</i>5</p></pre>
7984:
7985: <p>The parsing of this markup is straightforward up to the "3". At
7986: this point, the DOM looks like this:</p>
7987:
1.159 mike 7988: <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
7989: 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 7990: <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
7991: formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
7992: <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>
7993:
7994: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
7995: invoked. This is a simple case, in that the <var title="">formatting
7996: element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
7997: <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159 mike 7998: elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
7999: <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 8000: active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
8001: DOM tree is unmodified at this point.</p>
8002:
8003: <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
8004: the active formatting elements</a>, in this case just the
8005: <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
8006: for the "4" text node. After the end tag token for the "i" is also
8007: received, and the "5" text node is inserted, the DOM looks as
8008: follows:</p>
8009:
1.159 mike 8010: <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">9.2.8.2 </span>Misnested tags: <b><p></b></p></h5>
1.1 mike 8011:
8012: <p><i>This section is non-normative.</i></p>
8013:
8014: <p>A case similar to the previous one is the following:</p>
8015:
8016: <pre><b>1<p>2</b>3</p></pre>
8017:
8018: <p>Up to the "2" the parsing here is straightforward:</p>
8019:
1.159 mike 8020: <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 8021: "b" is parsed.</p>
8022:
8023: <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8024: elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8025: <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 8026: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
8027: <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>
8028:
8029: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
8030: in the previous example. However, in this case, there <em>is</em> a
8031: <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
8032: this time the adoption agency algorithm isn't skipped over.</p>
8033:
1.159 mike 8034: <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 8035: element. A conceptual "bookmark" marks the position of the
8036: <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
8037: elements</a>, but since that list has only one element in it,
8038: it won't have much effect.</p>
8039:
8040: <p>As the algorithm progresses, <var title="">node</var> ends up set
8041: to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
8042: node</var> ends up set to the <var title="">furthest block</var>
8043: (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
8044:
8045: <p>The <var title="">last node</var> gets appended (moved) to the
8046: <var title="">common ancestor</var>, so that the DOM looks like:</p>
8047:
1.159 mike 8048: <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 8049: <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
8050:
1.159 mike 8051: <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 8052: <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
8053:
1.159 mike 8054: <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 8055: active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
8056: elements</a>, so that when the "3" is parsed, it is appended to
8057: the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
8058:
1.614 mike 8059: <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">9.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 8060:
8061: <p><i>This section is non-normative.</i></p>
8062:
8063: <p>Error handling in tables is, for historical reasons, especially
8064: strange. For example, consider the following markup:</p>
8065:
8066: <pre><table><strong><b></strong><tr><td>aaa</td></tr><strong>bbb</strong></table>ccc</pre>
8067:
8068: <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
8069: directly inside a table like that, and the parser handles this case
8070: 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
8071: examining the DOM tree as it stands just after the
8072: <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
8073:
1.159 mike 8074: <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 8075: tag has been seen:</p>
8076:
1.159 mike 8077: <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
8078: 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 8079: <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
8080: resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
8081: elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
8082: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
8083: table">in table</a>".</p>
8084:
8085: <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
8086: to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
8087: 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
8088: then handled in a rather straight-forward manner, taking the parser
8089: through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
8090: body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
8091: row</a>" insertion modes, after which the DOM looks as
8092: follows:</p>
8093:
1.159 mike 8094: <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
8095: 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 8096: <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
8097: formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
8098: it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
8099: mode: in row">in row</a>".</p>
8100:
8101: <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
8102: <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
8103: 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
8104: mode</a>).</p>
8105:
1.159 mike 8106: <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 8107: no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
8108: node:</p>
8109:
1.159 mike 8110: <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 8111: handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159 mike 8112: 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 8113: 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
8114: elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
8115: marker having been removed by the "td" end tag token); and the
8116: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
8117: table body">in table body</a>".</p>
8118:
8119: <p>Thus it is that the "bbb" character tokens are found. These
8120: trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
8121: text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
8122: insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
8123: body">in table body</a>"). The character tokens are collected,
8124: and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
8125: seen, they are processed as a group. Since they are not all spaces,
8126: 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,
8127: which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
8128: body</a>" insertion mode but with <a href="#foster-parent" title="foster
8129: parent">foster parenting</a>.</p>
8130:
8131: <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
8132: active formatting elements are reconstructed</a>, a
8133: <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
8134: parent">foster parented</a>, and then the "bbb" text node is
8135: appended to it:</p>
8136:
1.159 mike 8137: <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
8138: <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 8139: <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
8140: this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
8141: formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
8142: and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
8143: mode: in table body">in table body</a>".</p>
8144:
8145: <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
8146: character">space characters</a> instead of "bbb", then those
8147: <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
8148: appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
8149:
8150: <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
8151: tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
8152: elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
8153: but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
8154: elements</a>, so the "ccc" character tokens after the table
8155: result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
8156: time after the table:</p>
8157:
1.614 mike 8158: <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">9.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 8159:
8160: <p><i>This section is non-normative.</i></p>
8161:
8162: <p>Consider the following markup, which for this example we will
8163: 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 8164: content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1 mike 8165: <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
8166:
8167: <pre><div id=a>
8168: <script>
8169: var div = document.getElementById('a');
8170: parent.document.body.appendChild(div);
8171: </script>
8172: <script>
8173: alert(document.URL);
8174: </script>
8175: </div>
8176: <script>
8177: alert(document.URL);
8178: </script></pre>
8179:
8180: <p>Up to the first "script" end tag, before the script is parsed,
8181: the result is relatively straightforward:</p>
8182:
1.306 mike 8183: <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="">
8184: </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 8185: and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
8186:
1.159 mike 8187: <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code></li></ul></li></ul><p>They are, at this point, in the <code>Document</code> of the
1.1 mike 8188: aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
8189: <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306 mike 8190: <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1 mike 8191:
8192: <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
8193: is inserted <em>into the outer <code>Document</code>
8194: object</em>.</p>
8195:
8196: <p>This also means that the <a href="browsers.html#script-s-global-object">script's global object</a> is
8197: the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
8198: object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159 mike 8199: <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1 mike 8200:
8201: <p class="note">This isn't a security problem since the script that
1.306 mike 8202: moves the <code><a href="semantics.html#the-div-element">div</a></code> into the outer <code>Document</code> can
1.1 mike 8203: only do so because they have the two <code>Document</code> object
1.159 mike 8204: have the same <a href="browsers.html#origin">origin</a>.</p>
1.1 mike 8205:
8206: <p>Thus, the first alert says "http://example.com/outer".</p>
8207:
1.306 mike 8208: <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
8209: <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.1 mike 8210: <code><a href="semantics.html#script">script</a></code> element is in the inner <code>Document</code>:</p>
8211:
1.159 mike 8212: <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 8213:
8214:
8215:
1.614 mike 8216: <h3 id="namespaces"><span class="secno">9.3 </span>Namespaces</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 8217:
8218: <p>The <dfn id="html-namespace-0">HTML namespace</dfn> is: <code>http://www.w3.org/1999/xhtml</code></p>
8219:
8220: <p>The <dfn id="mathml-namespace">MathML namespace</dfn> is: <code>http://www.w3.org/1998/Math/MathML</code></p>
8221:
8222: <p>The <dfn id="svg-namespace">SVG namespace</dfn> is: <code>http://www.w3.org/2000/svg</code></p>
8223:
8224: <p>The <dfn id="xlink-namespace">XLink namespace</dfn> is: <code>http://www.w3.org/1999/xlink</code></p>
8225:
8226: <p>The <dfn id="xml-namespace">XML namespace</dfn> is: <code>http://www.w3.org/XML/1998/namespace</code></p>
8227:
8228: <p>The <dfn id="xmlns-namespace">XMLNS namespace</dfn> is: <code>http://www.w3.org/2000/xmlns/</code></p>
8229:
8230: <hr><p>Data mining tools and other user agents that perform operations
1.605 mike 8231: on <code><a href="iana.html#text-html">text/html</a></code> content without running scripts,
1.1 mike 8232: evaluating CSS or XPath expressions, or otherwise exposing the
8233: resulting DOM to arbitrary content, may "support namespaces" by just
8234: asserting that their DOM node analogues are in certain namespaces,
8235: without actually exposing the above strings.</p>
8236:
8237:
8238:
8239:
1.614 mike 8240: <h3 id="serializing-html-fragments"><span class="secno">9.4 </span>Serializing HTML fragments</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 8241:
8242: <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
8243: algorithm</dfn>. The algorithm takes as input a DOM
8244: <code>Element</code> or <code>Document</code>, referred to as <var title="">the node</var>, and either returns a string or raises an
8245: exception.</p>
8246:
8247: <p class="note">This algorithm serializes the <em>children</em> of
8248: the node being serialized, not the node itself.</p>
8249:
8250: <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
8251: the empty string.</p></li>
8252:
8253: <li>
8254:
8255: <p>For each child node of <var title="">the node</var>, in
8256: <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
8257:
8258: </p><ol><li><p>Let <var title="">current node</var> be the child node
8259: being processed.</p></li>
8260:
8261: <li>
8262:
8263: <p>Append the appropriate string from the following list to
8264: <var title="">s</var>:</p>
8265:
8266: <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
8267:
8268: <dd>
8269:
1.588 mike 8270: <p>Append a U+003C LESS-THAN SIGN character character (<),
8271: followed by the element's tag name. (For nodes created by the
8272: <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1 mike 8273: lowercase.)</p>
8274:
8275: <p>For each attribute that the element has, append a U+0020
8276: SPACE character, the attribute's name (which, for attributes
8277: 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 8278: U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
8279: character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
8280: <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
8281: character (").</p>
1.1 mike 8282:
8283: <p>While the exact order of attributes is UA-defined, and may
8284: depend on factors such as the order that the attributes were
8285: given in the original markup, the sort order must be stable,
8286: such that consecutive invocations of this algorithm serialize an
8287: element's attributes in the same order.</p>
8288:
1.588 mike 8289: <p>Append a U+003E GREATER-THAN SIGN character (>).</p>
1.1 mike 8290:
8291: <p>If <var title="">current node</var> is an
1.5 mike 8292: <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.1 mike 8293: <code>bgsound</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 8294: <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>,
8295: <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 8296: <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
8297: <code>wbr</code> element, then continue on to the next child
8298: node at this point.</p> <!-- also, i guess: image and isindex,
8299: but we don't list those because we don't consider those
8300: "elements", more "macros", and thus we should never serialize
8301: them -->
1.1 mike 8302:
8303: <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42 mike 8304: <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 8305: a U+000A LINE FEED (LF) character.</p>
8306:
8307: <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
8308: serialization algorithm</a> on the <var title="">current
8309: node</var> element (thus recursing into this algorithm for
1.588 mike 8310: that element), followed by a U+003C LESS-THAN SIGN character
8311: (<), a U+002F SOLIDUS character (/), the element's tag name
8312: again, and finally a U+003E GREATER-THAN SIGN character
8313: (>).</p>
1.1 mike 8314:
8315: </dd>
8316:
8317:
8318: <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
8319: node</dt>
8320:
8321: <dd>
8322:
1.19 mike 8323: <p>If the parent of <var title="">current node</var> is a
1.42 mike 8324: <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 8325: <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 8326: <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
8327: if the parent of <var title="">current node</var> is
8328: <code><a href="semantics.html#the-noscript-element">noscript</a></code> element and <a href="browsers.html#concept-n-script" title="concept-n-script">scripting is enabled</a> for the
8329: node, then append the value of <var title="">current
8330: node</var>'s <code title="">data</code> IDL attribute
8331: literally.</p>
1.1 mike 8332:
8333: <p>Otherwise, append the value of <var title="">current
1.192 mike 8334: node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1 mike 8335: below</a>.</p>
8336:
8337: </dd>
8338:
8339:
8340: <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
8341:
8342: <dd>
8343:
8344: <p>Append the literal string <code><!--</code> (U+003C
8345: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192 mike 8346: U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8347: attribute, followed by the literal string <code>--></code>
8348: (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
8349: SIGN).</p>
8350:
8351: </dd>
8352:
8353:
8354: <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
8355:
8356: <dd>
8357:
8358: <p>Append the literal string <code><?</code> (U+003C
8359: LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192 mike 8360: of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
8361: U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8362: attribute, followed by a single U+003E GREATER-THAN SIGN
1.464 mike 8363: character (>).</p>
1.1 mike 8364:
8365: </dd>
8366:
8367:
8368: <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
8369:
8370: <dd>
8371:
8372: <p>Append the literal string <code><!DOCTYPE</code> (U+003C
8373: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
8374: LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
8375: LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
8376: LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
8377: LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192 mike 8378: value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1 mike 8379: string <code>></code> (U+003E GREATER-THAN SIGN).</p>
8380:
8381: </dd>
8382:
8383:
8384: </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
8385: occur as children of elements. If, despite this, they somehow do
8386: occur, this algorithm must raise an
8387: <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
8388:
8389: </li>
8390:
8391: </ol></li>
8392:
8393: <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
8394:
8395: </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
8396: purposes of the algorithm above) consists of replacing any
8397: occurrences of the "<code title="">&</code>" character by the
8398: string "<code title="">&amp;</code>", any occurrences of the
8399: U+00A0 NO-BREAK SPACE character by the string "<code title="">&nbsp;</code>", and, if the algorithm was invoked in
8400: 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
8401: 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>
8402:
8403: <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
8404: agent, and are therefore not covered in the algorithm above.</p>
8405:
8406: <p class="note">It is possible that the output of this algorithm, if
8407: parsed with an <a href="#html-parser">HTML parser</a>, will not return the
8408: original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
8409: element to which a <code title="">Comment</code> node has been
8410: appended is serialized and the output is then reparsed, the comment
8411: will end up being displayed in the text field. Similarly, if, as a
8412: result of DOM manipulation, an element contains a comment that
8413: contains the literal string "<code title="">--></code>", then
8414: when the result of serializing the element is parsed, the comment
8415: will be truncated at that point and the rest of the comment will be
8416: interpreted as markup. More examples would be making a
8417: <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
8418: "<code></script></code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
8419: 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
8420: <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
8421: tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
8422:
8423:
1.614 mike 8424: <h3 id="parsing-html-fragments"><span class="secno">9.5 </span>Parsing HTML fragments</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 8425:
8426: <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
8427: algorithm</dfn>. The algorithm optionally takes as input an
8428: <code>Element</code> node, referred to as the <var title="">context</var> element, which gives the context for the
8429: parser, as well as <var title="">input</var>, a string to parse, and
8430: returns a list of zero or more nodes.</p>
8431:
8432: <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
8433: in the parser section are parts that only occur if the parser was
8434: created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
8435: with such markings for informational purposes only; such markings
8436: have no normative weight. If it is possible for a condition
8437: described as a <a href="#fragment-case">fragment case</a> to occur even when the
8438: parser wasn't created for the purposes of handling this algorithm,
8439: then that is an error in the specification.</p>
8440:
8441: <ol><li>
8442:
8443: <p>Create a new <code>Document</code> node, and mark it as being
8444: an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
8445:
8446: </li>
8447:
8448: <li>
8449:
8450: <p>If there is a <var title="">context</var> element, and the
8451: <code>Document</code> of the <var title="">context</var> element
8452: is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code>Document</code>
8453: be in <a href="dom.html#quirks-mode">quirks mode</a>. Otherwise, if there is a <var title="">context</var> element, and the <code>Document</code> of
8454: the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited quirks
8455: mode</a>, then let the <code>Document</code> be in
8456: <a href="dom.html#limited-quirks-mode">limited quirks mode</a>. Otherwise, leave the
8457: <code>Document</code> in <a href="dom.html#no-quirks-mode">no quirks mode</a>.</p>
8458:
8459: </li>
8460:
8461: <li>
8462:
8463: <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
8464: the just created <code>Document</code> node.</p>
8465:
8466: </li>
8467:
8468: <li>
8469:
8470: <p>If there is a <var title="">context</var> element, run these
8471: substeps:</p>
8472:
8473: <ol><li>
8474:
1.541 mike 8475: <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
8476: <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1 mike 8477:
1.159 mike 8478: <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 8479: element</dt>
8480:
1.541 mike 8481: <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 8482:
8483:
8484: <dt>If it is a <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="semantics.html#script">script</a></code>,
1.159 mike 8485: <code><a href="obsolete.html#xmp">xmp</a></code>, <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 8486: <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1 mike 8487:
1.541 mike 8488: <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 8489:
8490:
8491: <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
8492:
1.541 mike 8493: <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
8494: tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>. Otherwise,
8495: leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8496:
8497:
1.42 mike 8498: <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1 mike 8499:
1.541 mike 8500: <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
8501: state</a>.</dd>
1.1 mike 8502:
8503:
8504: <dt>Otherwise</dt>
8505:
1.541 mike 8506: <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8507:
8508: </dl></li>
8509:
8510: <li>
8511:
1.159 mike 8512: <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 8513: with no attributes.</p>
8514:
8515: </li>
8516:
8517: <li>
8518:
8519: <p>Append the element <var title="">root</var> to the
8520: <code>Document</code> node created above.</p>
8521:
8522: </li>
8523:
8524: <li>
8525:
8526: <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
8527: it contains just the single element <var title="">root</var>.</p>
8528:
8529: </li>
8530:
8531: <li>
8532:
8533: <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
8534: parser's insertion mode appropriately</a>.</p>
8535:
8536: <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
8537:
8538: </li>
8539:
8540: <li>
8541:
8542: <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
8543: to the nearest node to the <var title="">context</var> element
8544: that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
8545: ancestor chain, and including the element itself, if it is a
8546: <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
8547: <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
8548:
8549: </li>
8550:
8551: </ol></li>
8552:
8553: <li>
8554:
8555: <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
8556: parser</a> just created the <var title="">input</var>. The
8557: encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
8558: <i>irrelevant</i>.</p>
8559:
8560: </li>
8561:
8562: <li>
8563:
8564: <p>Start the parser and let it run until it has consumed all the
8565: characters just inserted into the input stream.</p>
8566:
8567: </li>
8568:
8569: <li>
8570:
8571: <p>If there is a <var title="">context</var> element, return the
8572: child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
8573: order</a>.</p>
8574:
8575: <p>Otherwise, return the children of the <code>Document</code>
8576: object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
8577:
8578: </li>
8579:
1.123 mike 8580: </ol></div></body></html>
Webmaster