Annotation of html5/spec/syntax.html, revision 1.668
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.642 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">
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.642 mike 223:
1.123 mike 224: </div><nav>
1.1 mike 225: <a href="comms.html">← 8 Communication</a> –
1.2 mike 226: <a href="spec.html#contents">Table of contents</a> –
1.1 mike 227: <a href="named-character-references.html">9.6 Named character references →</a>
1.668 ! mike 228: </nav><p>This is revision 1.3516.</p>
1.659 mike 229:
1.1 mike 230:
1.123 mike 231: <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 232: <code><a href="iana.html#text-html">text/html</a></code> resources. Rules for XML resources are
1.1 mike 233: discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.614 mike 234: 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 235:
236: <p><i>This section only applies to documents, authoring tools, and
237: markup generators. In particular, it does not apply to conformance
238: checkers; conformance checkers must use the requirements given in
239: the next section ("parsing HTML documents").</i></p>
240:
1.123 mike 241: </div><p>Documents must consist of the following parts, in the given
242: order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1 mike 243:
244: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
245: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
246:
247: <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
248:
249: </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
250: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
251:
1.159 mike 252: <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 253:
254: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
255: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
256:
257: </ol><p>The various types of content mentioned above are described in the
1.123 mike 258: 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 259: declarations</a> are to be serialized, as discussed in the
1.123 mike 260: section on that topic.</p><div class="note">
1.1 mike 261:
1.159 mike 262: <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
263: space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
264: before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1 mike 265: document is parsed; space characters <em>after</em> the root
1.159 mike 266: <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
267: of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1 mike 268: root element do not round-trip.</p>
269:
270: <p>It is suggested that newlines be inserted after the DOCTYPE,
271: after any comments that are before the root element, after the
1.159 mike 272: <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
273: that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
274: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 275:
1.123 mike 276: </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1 mike 277: their attributes) are case-insensitive, but only for characters in
1.547 mike 278: the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
279: LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1 mike 280: LETTER Z). For convenience, in this section this is just referred to
1.614 mike 281: 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 282: but required, header.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1 mike 283: omitted, browsers tend to use a different rendering mode that is
284: incompatible with some specifications. Including the DOCTYPE in a
285: document ensures that the browser makes a best-effort attempt at
1.123 mike 286: following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.588 mike 287: order:</p><ol class="brief"><li>A U+003C LESS-THAN SIGN character (<).</li>
288: <li>A U+0021 EXCLAMATION MARK character (!).</li>
1.1 mike 289: <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>
290: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
291: <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>
292: <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> (defined below).</li>
293: <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.588 mike 294: <li>A U+003E GREATER-THAN SIGN character (>).</li>
1.1 mike 295: </ol><p class="note">In other words, <code><!DOCTYPE HTML></code>,
1.123 mike 296: case-insensitively.</p><p>For the purposes of HTML generators that cannot output HTML
1.1 mike 297: markup with the short DOCTYPE "<code title=""><!DOCTYPE
298: HTML></code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
299: into the DOCTYPE (in the position defined above). This string must
1.123 mike 300: 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 301: <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 302: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 303: <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465 mike 304: <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.1 mike 305: <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>
306: </ol><p class="note">In other words, <code><!DOCTYPE HTML SYSTEM
307: "about:legacy-compat"></code> or <code><!DOCTYPE HTML SYSTEM
308: 'about:legacy-compat'></code>, case-insensitively except for the bit
1.123 mike 309: in quotes.</p><p>The <a href="#doctype-legacy-string">DOCTYPE legacy string</a> should not be used unless
1.1 mike 310: the document is generated from a system that cannot output the
1.614 mike 311: 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 312: <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
313: <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 314:
315: <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 316: <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>,
317: <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 318: <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 319: <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 320:
1.373 mike 321: <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1 mike 322:
323: <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 324: noscript don't count as raw text for syntax purposes -->
1.1 mike 325:
1.373 mike 326: <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1 mike 327:
1.159 mike 328: <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 329:
1.373 mike 330: <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1 mike 331:
332: <dd>Elements from the <a href="#mathml-namespace">MathML namespace</a>
333: and the <a href="#svg-namespace">SVG namespace</a>.</dd>
334:
1.373 mike 335: <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1 mike 336:
337: <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
338: elements.</dd>
339:
340: </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373 mike 341: and end of elements in the markup. <a href="#raw-text-elements" title="raw text
342: elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
343: elements">RCDATA</a>, and <a href="#normal-elements" title="normal
344: elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
345: begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
346: indicate where they end. The start and end tags of certain
347: <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 348: later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
349: elements</a> only have a start tag; end tags must not be
1.373 mike 350: specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
351: elements</a> must either have a start tag and an end tag, or a
352: start tag that is marked as self-closing, in which case they must
353: not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1 mike 354: start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
355: in certain cases</a>) and just before the end tag (which again,
356: <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
357: cases</a>). The exact allowed contents of each individual element
358: depends on the content model of that element, as described earlier
359: in this specification. Elements must not contain content that their
360: content model disallows. In addition to the restrictions placed on
361: the contents by those content models, however, the five types of
1.123 mike 362: 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 363: no end tag, no content can be put between the start tag and the end
1.373 mike 364: 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
365: 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
366: must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1 mike 367: There are also <a href="#cdata-rcdata-restrictions">further
1.373 mike 368: restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
369: self-closing can't have any contents (since, again, as there's no
370: end tag, no content can be put between the start tag and the end
371: tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
372: 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 373: 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 374:
375: <p>The HTML syntax does not support namespace
376: declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
377:
378: <p>For instance, consider the following HTML fragment:</p>
379:
380: <pre><p>
381: <svg>
382: <metadata>
383: <!-- this is invalid -->
384: <cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/>
385: </metadata>
386: </svg>
387: </p></pre>
388:
389: <p>The innermost element, <code title="">cdr:license</code>, is
390: actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
391: XML). In fact, as the comment in the fragment above says, the
392: fragment is actually non-conforming. This is because the SVG
393: specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
394:
395: </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 396: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
397: <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1 mike 398: content they are allowed to hold, beyond the restrictions imposed by
399: the content model and those described in this paragraph. Those
1.123 mike 400: restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1 mike 401: giving the element's name. HTML elements all have names that only
1.464 mike 402: use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
403: NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
404: Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
405: Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462 mike 406: elements</a>, may be written with any mix of lower- and uppercase
407: letters that, when converted to all-lowercase, matches the element's
1.614 mike 408: 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 409: following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588 mike 410: SIGN character (<).</li>
1.1 mike 411:
412: <li>The next few characters of a start tag must be the element's
413: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
414:
415: <li>If there are to be any attributes in the next step, there must
416: first be one or more <a href="infrastructure.html#space-character" title="space character">space
417: characters</a>.</li>
418:
419: <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
420: below. Attributes may be separated from each other by one or more
421: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
422:
423: <li>After the attributes, there may be one or more <a href="infrastructure.html#space-character" title="space character">space characters</a>. (Some attributes
424: are required to be followed by a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes section</a> below.)</li>
425:
426: <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373 mike 427: or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588 mike 428: element</a>, then there may be a single U+002F SOLIDUS character
429: (/). This character has no effect on <a href="#void-elements">void elements</a>,
430: but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
431: self-closing.</li>
1.1 mike 432:
433: <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588 mike 434: SIGN character (>).</li>
1.1 mike 435:
1.614 mike 436: </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 437: following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588 mike 438: SIGN character (<).</li>
1.1 mike 439:
440: <li>The second character of an end tag must be a U+002F SOLIDUS
1.588 mike 441: character (/).</li>
1.1 mike 442:
443: <li>The next few characters of an end tag must be the element's
444: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
445:
446: <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
447: character">space characters</a>.</li>
448:
1.588 mike 449: <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
450: character (>).</li>
1.1 mike 451:
1.614 mike 452: </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 453: 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 454: one or more characters other than the <a href="infrastructure.html#space-character" title="space
455: character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
456: MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
457: (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
458: the control characters, and any characters that are not defined by
1.462 mike 459: Unicode. In the HTML syntax, attribute names, even those for
460: <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
461: and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123 mike 462: 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 463: 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 464: 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 465:
466: <dd>
467:
468: <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
469: name</a>.</p>
470:
471: <div class="example">
472:
473: <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
474: the empty attribute syntax:</p>
475:
476: <pre><input <em>disabled</em>></pre>
477:
478: </div>
479:
480: <p>If an attribute using the empty attribute syntax is to be
481: followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
482: character</a> separating the two.</p>
483:
484: </dd>
485:
1.2 mike 486: <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1 mike 487:
488: <dd>
489:
490: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
491: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
492: characters</a>, followed by a single U+003D EQUALS SIGN
493: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
494: character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
495: addition to the requirements given above for attribute values,
496: must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588 mike 497: characters</a>, any U+0022 QUOTATION MARK characters ("),
498: U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
499: characters (=), U+003C LESS-THAN SIGN characters (<), U+003E
500: GREATER-THAN SIGN characters (>), or U+0060 GRAVE ACCENT
501: characters (`), and must not be the empty string.</p>
1.463 mike 502:
503: <!-- The ` character is in this list on a temporary basis, waiting
504: for IE to fix it's parsing bug whereby it treats ` as an
505: attribute value delimiter. Otherwise, escaping software that
506: tries to be clever and not use quotes when it doesn't need to
507: could be tricked by an attacker.
508:
509: Posit a site that allows the user to input text that is used
510: verbatim in two attributes, such that the user can set the
511: first attribute's value to:
512:
513: `
514:
515: ...and the second to:
516:
517: ` onload='...payload...' end=x
518:
519: ...with the assumption that the site is going to not quote
520: the first one, and quote the second one with double quotes:
521:
522: <body title=` class="` onload='...payload...' end=x">
523:
524: In IE, this is treated as:
525:
526: <body title=' class="'
527: onload='...payload...'
528: end='x"'>
529:
530: -->
531:
1.1 mike 532:
533: <div class="example">
534:
535: <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
536: with the unquoted attribute value syntax:</p>
537:
538: <pre><input <em>value=yes</em>></pre>
539:
540: </div>
541:
542: <p>If an attribute using the unquoted attribute syntax is to be
1.101 mike 543: followed by another attribute or by the optional U+002F SOLIDUS
1.464 mike 544: 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 545: must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
546:
547: </dd>
548:
549: <dt>Single-quoted attribute value syntax</dt>
550:
551: <dd>
552:
553: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
554: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
555: characters</a>, followed by a single U+003D EQUALS SIGN
556: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
557: character">space characters</a>, followed by a single U+0027
1.588 mike 558: APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 559: addition to the requirements given above for attribute values,
1.588 mike 560: must not contain any literal U+0027 APOSTROPHE characters ('), and
561: finally followed by a second single U+0027 APOSTROPHE character
562: (').</p>
1.1 mike 563:
564: <div class="example">
565:
566: <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
567: single-quoted attribute value syntax:</p>
568:
569: <pre><input <em>type='checkbox'</em>></pre>
570:
571: </div>
572:
573: <p>If an attribute using the single-quoted attribute syntax is to
574: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
575: character</a> separating the two.</p>
576:
577: </dd>
578:
579: <dt>Double-quoted attribute value syntax</dt>
580:
581: <dd>
582:
583: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
584: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
585: characters</a>, followed by a single U+003D EQUALS SIGN
586: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
587: character">space characters</a>, followed by a single U+0022
1.588 mike 588: QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 589: addition to the requirements given above for attribute values,
1.588 mike 590: must not contain any literal U+0022 QUOTATION MARK characters ("),
591: and finally followed by a second single U+0022 QUOTATION MARK
592: character (").</p>
1.1 mike 593:
594: <div class="example">
595:
596: <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
597: double-quoted attribute value syntax:</p>
598:
599: <pre><input <em>name="be evil"</em>></pre>
600:
601: </div>
602:
603: <p>If an attribute using the double-quoted attribute syntax is to
604: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
605: character</a> separating the two.</p>
606:
607: </dd>
608:
609: </dl><p>There must never be two or more attributes on the same start tag
610: whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462 mike 611: each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
612: one of the namespaced attributes given by the local name and
613: namespace of the first and second cells of a row from the following
614: table, it must be written using the name given by the third cell
615: from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
616: </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>
617: </td></tr><tr><td> <code title="">arcrole</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:arcrole</code>
618: </td></tr><tr><td> <code title="">href</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:href</code>
619: </td></tr><tr><td> <code title="">role</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:role</code>
620: </td></tr><tr><td> <code title="">show</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:show</code>
621: </td></tr><tr><td> <code title="">title</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:title</code>
622: </td></tr><tr><td> <code title="">type</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:type</code>
623: </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>
624: </td></tr><tr><td> <code title="">lang</code> </td><td> <a href="#xml-namespace">XML namespace</a> </td><td> <code title="">xml:lang</code>
625: </td></tr><tr><td> <code title="">space</code> </td><td> <a href="#xml-namespace">XML namespace</a> </td><td> <code title="">xml:space</code>
626: </td></tr><tr><td> <code title="">xmlns</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns</code>
627: </td></tr><tr><td> <code title="">xlink</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns:xlink</code>
628: </td></tr></tbody></table><p>No other namespaced attribute can be expressed in the <a href="#syntax">the
1.614 mike 629: 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 630: is not present; it is implied, but it is still there. An HTML
1.159 mike 631: document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1 mike 632: string <code title=""><html></code> doesn't appear anywhere in
1.159 mike 633: 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
634: 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
635: tag</a> may be omitted if the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not
636: 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 637: element is empty, or--> if the first thing inside the
1.159 mike 638: <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
639: tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
640: 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
641: 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 642: 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 643: 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 644: <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
645: tag is present, the parser makes <style> and <script> elements
646: between </head> and <body> end up in the <head> instead of implying
1.159 mike 647: 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
648: 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 649: 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 650: tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
651: immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422 mike 652: 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 653: tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
654: immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123 mike 655: <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 656: tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
657: immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
658: <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123 mike 659: 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 660: tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
661: immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
662: <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 663: <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306 mike 664: <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 665: <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>,
666: <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>,
667: <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>,
668: <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>,
669: <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 670: <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>,
671: element, or if there is no more content in the parent element and
1.123 mike 672: 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 673: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
674: 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 675: 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 676: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
677: 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 678: 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 679: <select>; commented out text below can handle the non-<select> case
1.123 mike 680: 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 681: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
682: <code>select</code> element and--> is immediately followed by
683: another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
684: that are ancestors of the <code>optgroup</code> element, up to and
685: including the first ancestor element that is not an
686: <code>optgroup</code> element, have no more content--> there is no
1.123 mike 687: more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1 mike 688: <select><optgroup></select>
689: <p id=x><optgroup></optgroup>x</p>
690: <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
691: <p><optgroup id=x><optgroup></optgroup>x</p>
692: <p><optgroup><optgroup id=x>x</p>
1.123 mike 693: --><!-- </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 694: tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
695: immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
696: it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123 mike 697: 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 698: first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
699: <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
700: 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 701: 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 702: <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123 mike 703: <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 704: tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
705: 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 706: 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 707: first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
708: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
709: 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
710: <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
711: tag</a> has been omitted. (It can't be omitted if the element is
1.123 mike 712: 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 713: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
714: 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 715: 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 716: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
717: immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123 mike 718: 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 719: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
720: immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123 mike 721: 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 722: tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
723: 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 724: 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 725: tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
726: 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 727: 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 728: 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 729: 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 730: elements, even though these elements are technically allowed inside
731: <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
732: described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
733: 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 734: 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
735: placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1 mike 736: 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>
737: elements. This does not affect the processing of the element. The
1.304 mike 738: otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381 mike 739: <em>must</em> be included if the element's contents themselves start
740: with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
741: otherwise the leading newline in the contents would be treated like
742: the optional newline, and ignored).</p><div class="example">
1.1 mike 743: <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
744: <pre><pre>Hello</pre></pre>
745: <pre><pre><br>Hello</pre></pre>
1.614 mike 746: </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 747: <a href="#rcdata-elements" title="RCDATA elements">RCDATAs</a> element must not
748: contain any occurrences of the string "<code title=""></</code>"
749: (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that
1.1 mike 750: case-insensitively match the tag name of the element followed by one
751: of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM
1.304 mike 752: FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E
1.614 mike 753: 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 754: attributes, and comments. Text must consist of Unicode characters.
755: Text must not contain U+0000 characters. Text must not contain
1.316 mike 756: permanently undefined Unicode characters (noncharacters). Text must
757: not contain control characters other than <a href="infrastructure.html#space-character" title="space
758: character">space characters</a>. Extra constraints are placed on
759: what is and what is not allowed in text based on where the text is
1.614 mike 760: 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 761: represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
762: LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.614 mike 763: 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 764: to escape characters that couldn't otherwise legally be included in
1.588 mike 765: <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
766: (&). Following this, there are three possible kinds of character
767: references:</p><dl><dt>Named character references</dt>
1.1 mike 768:
769: <dd>The ampersand must be followed by one of the names given in the
770: <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
771: case. The name must be one that is terminated by a U+003B SEMICOLON
1.464 mike 772: character (;).</dd>
1.1 mike 773:
774:
775: <dt>Decimal numeric character reference</dt>
776:
777: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 778: character (#), followed by one or more digits in the range U+0030
779: DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
780: integer that corresponds to a Unicode code point that is allowed
781: according to the definition below. The digits must then be followed
782: by a U+003B SEMICOLON character (;).</dd>
1.1 mike 783:
784:
785: <dt>Hexadecimal numeric character reference</dt>
786:
787: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 788: character (#), which must be followed by either a U+0078 LATIN
789: SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
790: character (X), which must then be followed by one or more digits in
791: the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
792: LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
793: LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464 mike 794: representing a base-sixteen integer that corresponds to a Unicode
795: code point that is allowed according to the definition below. The
796: digits must then be followed by a U+003B SEMICOLON character
797: (;).</dd>
1.378 mike 798:
799: </dl><p>The numeric character reference forms described above are allowed
800: to reference any Unicode code point other than U+0000, permanently
801: undefined Unicode characters (noncharacters), and control characters
802: other than <a href="infrastructure.html#space-character" title="space character">space
803: characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464 mike 804: ampersand</dfn> is a U+0026 AMPERSAND character (&) that is
805: followed by some <a href="#syntax-text" title="syntax-text">text</a> other than a
806: <a href="infrastructure.html#space-character">space character</a>, a U+003C LESS-THAN SIGN character
1.614 mike 807: (<), 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 808: the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
809: MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
810: U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
811: LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
812: SQUARE BRACKET (<code title=""><![CDATA[</code>). Following this
813: sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
814: that the text must not contain the three character sequence U+005D
815: RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
816: GREATER-THAN SIGN (<code title="">]]></code>). Finally, the CDATA
817: section must be ended by the three character sequence U+005D RIGHT
818: SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.614 mike 819: 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 820: four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
821: MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title=""><!--</code>). Following this sequence, the comment may
822: have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
823: restriction that the text must not start with a single U+003E
1.588 mike 824: GREATER-THAN SIGN character (>), nor start with a U+002D
825: HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
826: (>) character, nor contain two consecutive U+002D HYPHEN-MINUS
827: characters (<code title="">--</code>), nor end with a U+002D
828: HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1 mike 829: the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123 mike 830: HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p><div class="impl">
1.1 mike 831:
1.159 mike 832: <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 833:
834: <p><i>This section only applies to user agents, data mining tools,
835: and conformance checkers.</i></p>
836:
837: <p class="note">The rules for parsing XML documents into DOM trees
838: are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
839: syntax</a>".</p>
840:
841: <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
842: rules described in this section to generate the DOM trees. Together,
843: these rules define what is referred to as the <dfn id="html-parser">HTML
844: parser</dfn>.</p>
845:
846: <div class="note">
847:
848: <p>While the HTML syntax described in this specification bears a
849: close resemblance to SGML and XML, it is a separate language with
850: its own parsing rules.</p>
851:
1.183 mike 852: <p>Some earlier versions of HTML (in particular from HTML2 to
853: HTML4) were based on SGML and used SGML parsing rules. However, few
1.1 mike 854: (if any) web browsers ever implemented true SGML parsing for HTML
855: documents; the only user agents to strictly handle HTML as an SGML
856: application have historically been validators. The resulting
857: confusion — with validators claiming documents to have one
858: representation while widely deployed Web browsers interoperably
859: implemented a different representation — has wasted decades
860: of productivity. This version of HTML thus returns to a non-SGML
861: basis.</p>
862:
863: <p>Authors interested in using SGML tools in their authoring
864: pipeline are encouraged to use XML tools and the XML serialization
865: of HTML.</p>
866:
867: </div>
868:
869: <p>This specification defines the parsing rules for HTML documents,
870: whether they are syntactically correct or not. Certain points in the
871: parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
872: errors</dfn>. The error handling for parse errors is well-defined:
873: user agents must either act as described below when encountering
874: such problems, or must abort processing at the first error that they
875: encounter for which they do not wish to apply the rules described
876: below.</p>
877:
878: <p>Conformance checkers must report at least one parse error
879: condition to the user if one or more parse error conditions exist in
880: the document and must not report parse error conditions if none
881: exist in the document. Conformance checkers may report more than one
1.174 mike 882: parse error condition if more than one parse error condition exists
1.1 mike 883: in the document. Conformance checkers are not required to recover
884: from parse errors.</p>
885:
886: <p class="note">Parse errors are only errors with the
887: <em>syntax</em> of HTML. In addition to checking for parse errors,
888: conformance checkers will also verify that the document obeys all
889: the other conformance requirements described in this
890: specification.</p>
891:
892: <p>For the purposes of conformance checkers, if a resource is
893: determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
894: <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
895:
1.266 mike 896: </div><div class="impl">
1.1 mike 897:
1.614 mike 898: <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 899:
900: <p>The input to the HTML parsing process consists of a stream of
901: Unicode characters, which is passed through a
902: <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
903: construction</a> stage. The output is a <code>Document</code>
904: object.</p>
905:
906: <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
907: support scripting</a> do not have to actually create a DOM
908: <code>Document</code> object, but the DOM tree in such cases is
909: still used as the model for the rest of the specification.</p>
910:
911: <p>In the common case, the data handled by the tokenization stage
1.159 mike 912: comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
913: 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 914:
915: <p><img alt="" src="images/parsing-model-overview.png"></p>
916:
917: <p id="nestedParsing">There is only one set of states for the
918: tokenizer stage and the tree construction stage, but the tree
919: construction stage is reentrant, meaning that while the tree
920: construction stage is handling one token, the tokenizer might be
921: resumed, causing further tokens to be emitted and processed before
922: the first token's processing is complete.</p>
923:
924: <div class="example">
925:
926: <p>In the following example, the tree construction stage will be
927: called upon to handle a "p" start tag token while handling the
928: "script" start tag token:</p>
929:
930: <pre>...
931: <script>
932: document.write('<p>');
933: </script>
934: ...</pre>
935:
936: </div>
937:
938: <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
939: level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
940: pause flag</dfn>, which must be initially set to false.</p>
941:
1.266 mike 942: </div><div class="impl">
1.1 mike 943:
1.614 mike 944: <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 945:
946: <p>The stream of Unicode characters that comprises the input to the
947: tokenization stage will be initially seen by the user agent as a
948: stream of bytes (typically coming over the network or from the local
949: file system). The bytes encode the actual characters according to a
950: particular <em>character encoding</em>, which the user agent must
951: use to decode the bytes into characters.</p>
952:
953: <p class="note">For XML documents, the algorithm user agents must
954: use to determine the character encoding is given by the XML
1.104 mike 955: specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1 mike 956:
957:
1.614 mike 958: <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 959:
960: <p>In some cases, it might be impractical to unambiguously determine
961: the encoding before parsing the document. Because of this, this
962: specification provides for a two-pass mechanism with an optional
963: pre-scan. Implementations are allowed, as described below, to apply
964: a simplified parsing algorithm to whatever bytes they have available
965: before beginning to parse the document. Then, the real parser is
966: started, using a tentative encoding derived from this pre-parse and
967: other out-of-band metadata. If, while the document is being loaded,
968: the user agent discovers an encoding declaration that conflicts with
969: this information, then the parser can get reinvoked to perform a
970: parse of the document with the real encoding.</p>
971:
972: <p id="documentEncoding">User agents must use the following
973: algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
974: the character encoding to use when decoding a document in the first
975: pass. This algorithm takes as input any out-of-band metadata
976: available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
977: and all the bytes available so far, and returns an encoding and a
978: <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
979: confidence is either <i>tentative</i>, <i>certain</i>, or
980: <i>irrelevant</i>. The encoding used, and whether the confidence in
981: that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
982: determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
983: encoding is necessary, e.g. because the parser is operating on a
984: stream of Unicode characters and doesn't have to use an encoding at
985: all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
986: <i>irrelevant</i>.</p>
987:
988: <ol><li><p>If the transport layer specifies an encoding, and it is
989: supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
990: <i>certain</i>, and abort these steps.</p></li>
991:
992: <li><p>The user agent may wait for more bytes of the resource to be
993: available, either in this step or at any later step in this
994: algorithm. For instance, a user agent might wait 500ms or 512
995: bytes, whichever came first. In general preparsing the source to
996: find the encoding improves performance, as it reduces the need to
997: throw away the data structures used when parsing upon finding the
998: encoding information. However, if the user agent delays too long to
999: obtain data to determine the encoding, then the cost of the delay
1000: could outweigh any performance improvements from the
1001: preparse.</p></li>
1002:
1003: <li><p>For each of the rows in the following table, starting with
1004: the first one and going down, if there are as many or more bytes
1005: available than the number of bytes in the first column, and the
1006: first bytes of the file match the bytes given in the first column,
1007: then return the encoding given in the cell in the second column of
1008: that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1009: <i>certain</i>, and abort these steps:</p>
1010:
1011: <!-- this table is present in several forms in this file; keep them in sync -->
1012: <table><thead><tr><th>Bytes in Hexadecimal
1013: </th><th>Encoding
1014: </th></tr></thead><tbody><!-- nobody uses this
1015: <tr>
1016: <td>00 00 FE FF
1017: <td>UTF-32BE
1018: <tr>
1019: <td>FF FE 00 00
1020: <td>UTF-32LE
1021: --><tr><td>FE FF
1022: </td><td>UTF-16BE
1023: </td></tr><tr><td>FF FE
1024: </td><td>UTF-16LE
1025: </td></tr><tr><td>EF BB BF
1026: </td><td>UTF-8
1027: <!-- nobody uses this
1028: <tr>
1029: <td>DD 73 66 73
1030: <td>UTF-EBCDIC
1031: -->
1032: </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
1033: (BOMs).</p></li>
1034:
1035: <li><p>Otherwise, the user agent will have to search for explicit
1036: character encoding information in the file itself. This should
1037: proceed as follows:
1038:
1039: </p><p>Let <var title="">position</var> be a pointer to a byte in the
1040: input stream, initially pointing at the first byte. If at any
1041: point during these substeps the user agent either runs out of
1042: bytes or decides that scanning further bytes would not be
1043: efficient, then skip to the next step of the overall character
1044: encoding detection algorithm. User agents may decide that scanning
1045: <em>any</em> bytes is not efficient, in which case these substeps
1046: are entirely skipped.</p>
1047:
1048: <p>Now, repeat the following "two" steps until the algorithm
1049: aborts (either because user agent aborts, as described above, or
1050: because a character encoding is found):</p>
1051:
1052: <ol><li><p>If <var title="">position</var> points to:</p>
1053:
1054: <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '<!--')</dt>
1055: <dd>
1056:
1057: <p>Advance the <var title="">position</var> pointer so that it
1058: points at the first 0x3E byte which is preceded by two 0x2D
1059: bytes (i.e. at the end of an ASCII '-->' sequence) and comes
1060: after the 0x3C byte that was found. (The two 0x2D bytes can be
1061: the same as the those in the '<!--' sequence.)</p>
1062:
1063: </dd>
1064:
1065: <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>
1066: <dd>
1067:
1068: <ol><li><p>Advance the <var title="">position</var> pointer so
1069: that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
1070: 0x2F byte (the one in sequence of characters matched
1071: above).</p></li>
1072:
1073: <li><p><a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get
1074: an attribute</a> and its value. If no attribute was
1075: sniffed, then skip this inner set of steps, and jump to the
1076: second step in the overall "two step" algorithm.</p></li>
1077:
1078: <li><p>If the attribute's name is neither "<code title="">charset</code>" nor "<code title="">content</code>",
1079: then return to step 2 in these inner steps.</p></li>
1080:
1081: <li><p>If the attribute's name is "<code title="">charset</code>", let <var title="">charset</var> be
1082: the attribute's value, interpreted as a character
1083: encoding.</p></li>
1084:
1085: <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
1086: extracting an encoding from a Content-Type</a>, giving the
1087: attribute's value as the string to parse. If an encoding is
1088: returned, let <var title="">charset</var> be that
1089: encoding. Otherwise, return to step 2 in these inner
1090: steps.</p></li>
1091:
1092: <li><p>If <var title="">charset</var> is a UTF-16 encoding,
1093: change the value of <var title="">charset</var> to
1094: UTF-8.</p></li>
1095:
1096: <li><p>If <var title="">charset</var> is a supported
1097: character encoding, then return the given encoding, with
1098: <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1099: <i>tentative</i>, and abort all these steps.</p></li>
1100:
1101: <li><p>Otherwise, return to step 2 in these inner
1102: steps.</p></li>
1103:
1104: </ol></dd>
1105:
1.464 mike 1106: <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 1107: <dd>
1108:
1109: <ol><li><p>Advance the <var title="">position</var> pointer so
1110: that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
1111: 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464 mike 1112: (ASCII >) byte.</p></li>
1.1 mike 1113:
1114: <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
1115: attribute</a> until no further attributes can be found,
1116: then jump to the second step in the overall "two step"
1117: algorithm.</p></li>
1118:
1119: </ol></dd>
1120:
1121: <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '<!')</dt>
1122: <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '</')</dt>
1123: <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '<?')</dt>
1124: <dd>
1125:
1126: <p>Advance the <var title="">position</var> pointer so that it
1.464 mike 1127: points at the first 0x3E byte (ASCII >) that comes after the
1.1 mike 1128: 0x3C byte that was found.</p>
1129:
1130: </dd>
1131:
1132: <dt>Any other byte</dt>
1133: <dd>
1134:
1135: <p>Do nothing with that byte.</p>
1136:
1137: </dd>
1138:
1139: </dl></li>
1140:
1141: <li>Move <var title="">position</var> so it points at the next
1142: byte in the input stream, and return to the first step of this
1143: "two step" algorithm.</li>
1144:
1145: </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
1146: attribute</dfn>, it means doing this:</p>
1147:
1148: <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
1149: (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464 mike 1150: 0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1 mike 1151: substep.</p></li>
1152:
1153: <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464 mike 1154: >), then abort the "get an attribute" algorithm. There isn't
1.1 mike 1155: one.</p></li>
1156:
1157: <li><p>Otherwise, the byte at <var title="">position</var> is the
1158: start of the attribute name. Let <var title="">attribute
1159: name</var> and <var title="">attribute value</var> be the empty
1160: string.</p></li>
1161:
1162: <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
1163:
1.464 mike 1164: <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1 mike 1165: name</var> is longer than the empty string</dt>
1166:
1167: <dd>Advance <var title="">position</var> to the next byte and
1168: jump to the step below labeled <i>value</i>.</dd>
1169:
1170: <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1171: FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
1172:
1173: <dd>Jump to the step below labeled <i>spaces</i>.</dd>
1174:
1.464 mike 1175: <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII >)</dt>
1.1 mike 1176:
1177: <dd>Abort the "get an attribute" algorithm. The attribute's
1178: name is the value of <var title="">attribute name</var>, its
1179: value is the empty string.</dd>
1180:
1.464 mike 1181: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1182: Z)</dt>
1.1 mike 1183:
1184: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1185: name</var> (where <var title="">b</var> is the value of the
1186: byte at <var title="">position</var>).</dd>
1187:
1188: <dt>Anything else</dt>
1189:
1190: <dd>Append the Unicode character with the same code point as the
1191: value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
1192: bytes outside the ASCII range are handled here, since only
1193: ASCII characters can contribute to the detection of a character
1194: encoding.)</dd>
1195:
1196: </dl></li>
1197:
1198: <li><p>Advance <var title="">position</var> to the next byte and
1199: return to the previous step.</p></li>
1200:
1201: <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1202: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1203: advance <var title="">position</var> to the next byte, then,
1204: repeat this step.</p></li>
1205:
1206: <li><p>If the byte at <var title="">position</var> is
1.464 mike 1207: <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1 mike 1208: algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
1209: string.</p></li>
1210:
1211: <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464 mike 1212: =) byte.</p></li>
1.1 mike 1213:
1214: <li><p><i>Value:</i> If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1215: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1216: advance <var title="">position</var> to the next byte, then,
1217: repeat this step.</p></li>
1218:
1219: <li><p>Process the byte at <var title="">position</var> as
1220: follows:</p>
1221:
1.464 mike 1222: <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1 mike 1223:
1224: <dd>
1225:
1226: <ol><li>Let <var title="">b</var> be the value of the byte at
1227: <var title="">position</var>.</li>
1228:
1229: <li>Advance <var title="">position</var> to the next
1230: byte.</li>
1231:
1232: <li>If the value of the byte at <var title="">position</var>
1233: is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
1234: an attribute" algorithm. The attribute's name is the value of
1235: <var title="">attribute name</var>, and its value is the
1236: value of <var title="">attribute value</var>.</li>
1237:
1.464 mike 1238: <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
1239: 0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1 mike 1240: than the value of the byte at <var title="">position</var>.</li>
1241:
1242: <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
1243: the value of the byte at <var title="">position</var>.</li>
1244:
1245: <li>Return to the second step in these substeps.</li>
1246:
1247: </ol></dd>
1248:
1.464 mike 1249: <dt>If it is 0x3E (ASCII >)</dt>
1.1 mike 1250:
1251: <dd>Abort the "get an attribute" algorithm. The attribute's
1252: name is the value of <var title="">attribute name</var>, its
1253: value is the empty string.</dd>
1254:
1255:
1.464 mike 1256: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1257: Z)</dt>
1.1 mike 1258:
1259: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1260: value</var> (where <var title="">b</var> is the value of the
1261: byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
1262:
1263: <dt>Anything else</dt>
1264:
1265: <dd>Append the Unicode character with the same code point as the
1266: 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>
1267:
1268: </dl></li>
1269:
1270: <li><p>Process the byte at <var title="">position</var> as
1271: follows:</p>
1272:
1273: <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1274: FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464 mike 1275: >)</dt>
1.1 mike 1276:
1277: <dd>Abort the "get an attribute" algorithm. The attribute's
1278: name is the value of <var title="">attribute name</var> and its
1279: value is the value of <var title="">attribute value</var>.</dd>
1280:
1.464 mike 1281: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1282: Z)</dt>
1.1 mike 1283:
1284: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1285: value</var> (where <var title="">b</var> is the value of the
1286: byte at <var title="">position</var>).</dd>
1287:
1288: <dt>Anything else</dt>
1289:
1290: <dd>Append the Unicode character with the same code point as the
1291: value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
1292:
1293: </dl></li>
1294:
1295: <li><p>Advance <var title="">position</var> to the next byte and
1296: return to the previous step.</p></li>
1297:
1298: </ol><p>For the sake of interoperability, user agents should not use a
1299: pre-scan algorithm that returns different results than the one
1300: described above. (But, if you do, please at least let us know, so
1301: that we can improve this algorithm and benefit everyone...)</p>
1302:
1303: </li>
1304:
1305: <li><p>If the user agent has information on the likely encoding for
1306: this page, e.g. based on the encoding of the page when it was last
1307: visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1308: <i>tentative</i>, and abort these steps.</p></li>
1309:
1.322 mike 1310: <li>
1311:
1312: <p>The user agent may attempt to autodetect the character encoding
1313: from applying frequency analysis or other algorithms to the data
1.568 mike 1314: stream. Such algorithms may use information about the resource
1315: other than the resource's contents, including the address of the
1316: resource. If autodetection succeeds in determining a character
1.322 mike 1317: encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1318: <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
1319:
1320: <p class="note">The UTF-8 encoding has a highly detectable bit
1321: pattern. Documents that contain bytes with values greater than
1322: 0x7F which match the UTF-8 pattern are very likely to be UTF-8,
1323: while documents with byte sequences that do not match it are very
1324: likely not. User-agents are therefore encouraged to search for
1.485 mike 1325: this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322 mike 1326:
1327: </li>
1.1 mike 1328:
1.501 mike 1329: <li>
1330:
1331: <p>Otherwise, return an implementation-defined or user-specified
1332: default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1333: <i>tentative</i>.</p>
1334:
1335: <p>In controlled environments or in environments where the
1336: encoding of documents can be prescribed (for example, for user
1337: agents intended for dedicated use in new networks), the
1338: comprehensive <code title="">UTF-8</code> encoding is
1339: suggested.</p>
1340:
1341: <p>In other environments, the default encoding is typically
1342: dependent on the user's locale (an approximation of the languages,
1343: and thus typically encodings, of the pages that the user is likely
1344: to frequent). The following table gives suggested defaults based
1.504 mike 1345: on the user's locale, for compatibility with legacy
1346: content. Locales are identified by BCP 47 language codes. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501 mike 1347:
1348: <!-- based on mozilla 1.9.1 localizations:
1349: http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
1350:
1.504 mike 1351: <table><thead><tr><th>Locale language
1.501 mike 1352: </th><th>Suggested default encoding
1353: </th></tr></thead><tbody><tr><td>ar
1354: </td><td>UTF-8
1355:
1356: </td></tr><tr><td>be
1357: </td><td>ISO-8859-5
1358:
1359: </td></tr><tr><td>bg
1360: </td><td>windows-1251
1361:
1362: </td></tr><tr><td>cs<!-- -CZ -->
1363: </td><td>ISO-8859-2
1364:
1365: </td></tr><tr><td>cy
1366: </td><td>UTF-8
1367:
1368: </td></tr><tr><td>fa<!-- -IR -->
1369: </td><td>UTF-8
1370:
1371: </td></tr><tr><td>he<!-- -IL -->
1372: </td><td>windows-1255
1373:
1374: </td></tr><tr><td>hr
1375: </td><td>UTF-8
1376:
1377: </td></tr><tr><td>hu<!-- -HU -->
1378: </td><td>ISO-8859-2
1379:
1380: </td></tr><tr><td>ja <!-- and ja-JP-mac -->
1381: </td><td>windows-31J <!-- Shift_JIS -->
1382:
1383: </td></tr><tr><td>kk
1384: </td><td>UTF-8
1385:
1386: </td></tr><tr><td>ko<!-- -KR -->
1387: </td><td>windows-949 <!-- EUC-KR -->
1388:
1389: </td></tr><tr><td>ku
1390: </td><td>windows-1254 <!-- ISO-8859-9 -->
1391:
1392: </td></tr><tr><td>lt
1393: </td><td>windows-1257
1394:
1395: </td></tr><tr><td>lv<!-- -LV -->
1396: </td><td>ISO-8859-13
1397:
1398: </td></tr><tr><td>mk<!-- -MK -->
1399: </td><td>UTF-8
1400:
1401: </td></tr><tr><td>or
1402: </td><td>UTF-8
1403:
1404: </td></tr><tr><td>pl<!-- -PL -->
1405: </td><td>ISO-8859-2
1406:
1407: </td></tr><tr><td>ro
1408: </td><td>UTF-8
1409:
1410: </td></tr><tr><td>ru
1411: </td><td>windows-1251
1412:
1413: </td></tr><tr><td>sk
1414: </td><td>windows-1250
1415:
1416: </td></tr><tr><td>sl
1417: </td><td>ISO-8859-2
1418:
1419: </td></tr><tr><td>sr
1420: </td><td>UTF-8
1421:
1422: </td></tr><tr><td>th
1423: </td><td>windows-874 <!-- TIS-620 -->
1424:
1425: </td></tr><tr><td>tr<!-- -TR -->
1426: </td><td>windows-1254 <!-- ISO-8859-9 -->
1427:
1.503 mike 1428: </td></tr><tr><td>uk
1.501 mike 1429: </td><td>windows-1251
1430:
1431: </td></tr><tr><td>vi
1432: </td><td>UTF-8
1433:
1434: </td></tr><tr><td>zh-CN
1435: </td><td>GB18030
1436:
1437: </td></tr><tr><td>zh-TW
1438: </td><td>Big5
1439:
1440: </td></tr><tr><td>All other locales
1441: </td><td>windows-1252
1442:
1443: </td></tr></tbody></table></li>
1.1 mike 1444:
1445: </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
1446: be set to the value returned from this algorithm, at the same time
1447: as the user agent uses the returned value to select the decoder to
1448: use for the input stream.</p>
1449:
1.582 mike 1450: <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
1451: of the HTTP specification, which requires that the encoding be
1452: assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1.647 mike 1453: encoding declaration</a> to the contrary, and of RFC 2046,
1.582 mike 1454: which requires that the encoding be assumed to be US-ASCII in the
1455: absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
1456: contrary. This specification's third approach is motivated by a
1457: desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
1458:
1.1 mike 1459:
1.614 mike 1460: <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 1461:
1.237 mike 1462: <p>User agents must at a minimum support the UTF-8 and Windows-1252
1463: encodings, but may support more.</p>
1464:
1465: <p class="note">It is not unusual for Web browsers to support dozens
1466: if not upwards of a hundred distinct character encodings.</p>
1467:
1.365 mike 1468: <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
1469: every character encoding they support, and should support all the
1470: IANA-registered names and aliases of every character encoding they
1471: support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237 mike 1472:
1473: <p>When comparing a string specifying a character encoding with the
1474: name or alias of a character encoding to determine if they are
1475: 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
1476: then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1477: case-insensitive</a> manner.</p>
1478:
1.539 mike 1479: <hr><p>When a user agent would otherwise use an encoding given in the
1.237 mike 1480: first column of the following table to either convert content to
1481: Unicode characters or convert Unicode characters to bytes, it must
1482: instead use the encoding given in the cell in the second column of
1483: the same row. When a byte or sequence of bytes is treated
1484: differently due to this encoding aliasing, it is said to have been
1485: <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
1486:
1487: <table><caption>Character encoding overrides</caption>
1488: <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
1489: </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
1490: <a href="references.html#refsEUCKR">[EUCKR]</a>
1491: <a href="references.html#refsWIN949">[WIN949]</a>
1492: </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
1493: <a href="references.html#refsRFC1345">[RFC1345]</a>
1494: <a href="references.html#refsGBK">[GBK]</a>
1495: </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
1496: <a href="references.html#refsRFC1345">[RFC1345]</a>
1497: <a href="references.html#refsGBK">[GBK]</a>
1498: </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
1499: <a href="references.html#refsRFC1345">[RFC1345]</a>
1500: <a href="references.html#refsWIN1252">[WIN1252]</a>
1501: </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
1502: <a href="references.html#refsRFC1345">[RFC1345]</a>
1503: <a href="references.html#refsWIN1254">[WIN1254]</a>
1504: </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
1505: <a href="references.html#refsISO885911">[ISO885911]</a>
1506: <a href="references.html#refsWIN874">[WIN874]</a>
1507: </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
1508: <a href="references.html#refsRFC1345">[RFC1345]</a>
1509: <a href="references.html#refsWIN949">[WIN949]</a>
1510: </td></tr><tr><td> Shift_JIS </td><td> windows-31J </td><td>
1511: <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
1512: <a href="references.html#refsWIN31J">[WIN31J]</a>
1513: </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
1514: <a href="references.html#refsTIS620">[TIS620]</a>
1515: <a href="references.html#refsWIN874">[WIN874]</a>
1516: </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
1517: <a href="references.html#refsRFC1345">[RFC1345]</a>
1518: <a href="references.html#refsWIN1252">[WIN1252]</a>
1519: </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
1520: encodings according to the table above is a <a href="introduction.html#willful-violation">willful
1521: violation</a> of the W3C Character Model specification, motivated
1522: by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
1523:
1524: <p>When a user agent is to use the UTF-16 encoding but no BOM has
1525: been found, user agents must default to UTF-16LE.</p>
1526:
1527: <p class="note">The requirement to default UTF-16 to LE rather than
1528: BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581 mike 1529: desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237 mike 1530:
1531: <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
1532: 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>
1533:
1534: <p>Support for encodings based on EBCDIC is not recommended. This
1535: encoding is rarely used for publicly-facing Web content.</p>
1536:
1537: <p>Support for UTF-32 is not recommended. This encoding is rarely
1538: used, and frequently implemented incorrectly.</p>
1539:
1540: <p class="note">This specification does not make any attempt to
1541: support EBCDIC-based encodings and UTF-32 in its algorithms; support
1542: and use of these encodings can thus lead to unexpected behavior in
1543: implementations of this specification.</p>
1544:
1545:
1546:
1.614 mike 1547: <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 1548:
1549: <p>Given an encoding, the bytes in the input stream must be
1550: converted to Unicode characters for the tokenizer, as described by
1551: the rules for that encoding, except that the leading U+FEFF BYTE
1552: ORDER MARK character, if any, must not be stripped by the encoding
1553: layer (it is stripped by the rule below).</p> <!-- this is to
1554: prevent two leading BOMs from being both stripped, once by the
1555: decoder, and once by the parser -->
1556:
1557: <p>Bytes or sequences of bytes in the original byte stream that
1.393 mike 1558: could not be converted to Unicode code points must be converted to
1559: U+FFFD REPLACEMENT CHARACTERs.</p>
1.1 mike 1560:
1561: <p class="note">Bytes or sequences of bytes in the original byte
1562: stream that did not conform to the encoding specification
1563: (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
1564: errors that conformance checkers are expected to report.</p>
1565:
1.438 mike 1566: <p>Any byte or sequence of bytes in the original byte stream that is
1567: <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1 mike 1568: error</a>.</p>
1569:
1570: <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
1571: any are present.</p>
1572:
1.300 mike 1573: <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
1574: character regardless of whether that character was used to determine
1575: the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
1576: motivated by a desire to increase the resilience of user agents in
1577: the face of naïve transcoders.</p>
1578:
1.316 mike 1579: <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315 mike 1580: U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
1581: them to suddenly turn into codepoints when they go through a UTF-16
1582: pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316 mike 1583: CHARACTERs. Any occurrences of such characters and code points are
1584: <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1 mike 1585:
1586: <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
1587: <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
1588: CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315 mike 1589: <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
1590: to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
1591: U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
1592: U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
1593: U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
1594: U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
1595: U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316 mike 1596: errors</a>. These are all control characters or permanently
1597: undefined Unicode characters (noncharacters).</p>
1.1 mike 1598:
1599: <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
1600: characters are treated specially. Any CR characters that are
1601: followed by LF characters must be removed, and any CR characters not
1602: followed by LF characters must be converted to LF characters. Thus,
1603: newlines in HTML DOMs are represented by LF characters, and there
1604: are never any CR characters in the input to the
1605: <a href="#tokenization">tokenization</a> stage.</p>
1606:
1607: <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
1608: input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
1609: the <i><a href="#next-input-character">next input character</a></i> is the first character in the
1610: input. The <dfn id="current-input-character">current input character</dfn> is the last character
1611: to have been <i><a href="#consumed">consumed</a></i>.</p>
1612:
1613: <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
1614: character or just before the end of the input stream) where content
1.159 mike 1615: 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 1616: inserted. The insertion point is relative to the position of the
1617: character immediately after it, it is not an absolute offset into
1618: the input stream. Initially, the insertion point is
1.10 mike 1619: undefined.</p>
1.1 mike 1620:
1621: <p>The "EOF" character in the tables below is a conceptual character
1622: representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159 mike 1623: is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1 mike 1624: <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159 mike 1625: 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 1626: consumed. Otherwise, the "EOF" character is not a real character in
1627: the stream, but rather the lack of any further characters.</p>
1628:
1629:
1.614 mike 1630: <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 1631:
1632: <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
1633: encoding</dfn>, it must run the following steps. This might happen
1634: if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
1635: failed to find an encoding, or if it found an encoding that was not
1636: the actual encoding of the file.</p>
1637:
1638: <ol><li>If the new encoding is identical or equivalent to the encoding
1639: that is already being used to interpret the input stream, then set
1640: the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1641: <i>certain</i> and abort these steps. This happens when the
1642: encoding information found in the file matches what the
1643: <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
1644: encoding, and in the second pass through the parser if the first
1645: pass found that the encoding sniffing algorithm described in the
1646: earlier section failed to find the right encoding.</li>
1647:
1648: <li>If the encoding that is already being used to interpret the
1649: input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1650: <i>certain</i> and abort these steps. The new encoding is ignored;
1651: if it was anything but the same encoding, then it would be clearly
1652: incorrect.</li>
1653:
1654: <li>If the new encoding is a UTF-16 encoding, change it to
1655: UTF-8.</li>
1656:
1657: <li>If all the bytes up to the last byte converted by the current
1658: decoder have the same Unicode interpretations in both the current
1659: encoding and the new encoding, and if the user agent supports
1660: changing the converter on the fly, then the user agent may change
1661: to the new converter for the encoding on the fly. Set the
1662: <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
1663: convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1664: <i>certain</i>, and abort these steps.</li>
1665:
1666: <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
1667: <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
1668: browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
1669: sniffing algorithm</a> and instead just set the encoding to the
1670: new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1671: <i>certain</i>. Whenever possible, this should be done without
1672: actually contacting the network layer (the bytes should be
1673: re-parsed from memory), even if, e.g., the document is marked as
1674: not being cacheable. If this is not possible and contacting the
1675: network layer would involve repeating a request that uses a method
1676: other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
1677: equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1678: <i>certain</i> and ignore the new encoding. The resource will be
1679: misinterpreted. User agents may notify the user of the situation,
1680: to aid in application development.</li>
1681:
1.266 mike 1682: </ol></div><div class="impl">
1683:
1.614 mike 1684: <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 1685:
1.614 mike 1686: <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 1687:
1688: <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
1689: the primary operation of the tree construction stage.</p>
1690:
1691: <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
1692: "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
1693: "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
1694: "<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 1695: "<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 1696: "<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>",
1697: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
1698: "<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
1699: table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
1700: foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
1701: body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
1702: frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
1703: frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
1704: after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
1705: frameset</a>" during the course of the parsing, as described in
1706: the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
1707: how tokens are processed and whether CDATA sections are
1708: supported.</p>
1709:
1710: <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
1711: head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
1712: body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
1713: table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
1714: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
1715: "<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
1716: that the other modes defer to them at various times. When the
1717: algorithm below says that the user agent is to do something
1718: "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
1719: mode", where <var title="">m</var> is one of these modes, the user
1720: agent must use the rules described under the <var title="">m</var>
1721: <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
1722: <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>
1723: to a new value.</p>
1724:
1725: <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540 mike 1726: mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
1727: text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
1728: is also set. This is the insertion mode to which the tree
1729: construction stage will return.</p>
1.1 mike 1730:
1731: <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
1732: mode: in foreign content">in foreign content</a>", the
1733: <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
1734: is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
1735: foreign content">in foreign content</a>" mode to handle HTML
1736: (i.e. not foreign) content.</p>
1737:
1738: <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
1739: mode appropriately</dfn>, it means the UA must follow these
1740: steps:</p>
1741:
1742: <ol><li>Let <var title="">last</var> be false.</li>
1743:
1.604 mike 1744: <li>Let <var title="">foreign</var> be false.</li>
1745:
1.1 mike 1746: <li>Let <var title="">node</var> be the last node in the
1747: <a href="#stack-of-open-elements">stack of open elements</a>.</li>
1748:
1.604 mike 1749: <li><i>Loop</i>: If <var title="">node</var> is the first node in
1750: the stack of open elements, then set <var title="">last</var> to
1751: 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 1752:
1753: <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604 mike 1754: 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
1755: step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1 mike 1756:
1757: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
1758: <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
1759: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.604 mike 1760: mode: in cell">in cell</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1761:
1762: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
1763: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.604 mike 1764: mode: in row">in row</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1765:
1766: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
1767: <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
1768: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.604 mike 1769: table body">in table body</a>" and jump to the step marked <i title="">end</i>.</li>
1.1 mike 1770:
1771: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604 mike 1772: 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
1773: the step marked <i title="">end</i>.</li>
1.1 mike 1774:
1775: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
1776: 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 1777: jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1778: case</a>)</li>
1.1 mike 1779:
1780: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604 mike 1781: 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
1782: step marked <i title="">end</i>.</li>
1.1 mike 1783:
1.159 mike 1784: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604 mike 1785: 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
1786: the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1787: case</a>)</li> <!-- This is only here for now in case people
1788: think that the spec accidentally omitted it and try to "fix"
1789: it. Note that noscript-in-head is also handled this way. This is
1790: all intentional. The only thing it doesn't handle is the
1791: scripting-disabled fragment parsing case for a <head> element
1792: containing a <noscript> which itself contains something other than
1793: a <link> or a <style> element; you'd expect that to break out of
1794: the <noscript> but it doesn't. This is an edge case that doesn't
1795: affect the spec, since the algorithm for fragment parsing is only
1796: used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
1797: scripting is enabled. -->
1.1 mike 1798:
1.159 mike 1799: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604 mike 1800: 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
1801: step marked <i title="">end</i>.</li>
1.1 mike 1802:
1.5 mike 1803: <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604 mike 1804: 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
1805: the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
1806: case</a>)</li>
1.1 mike 1807:
1.159 mike 1808: <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333 mike 1809: then <!--: if the <span><code title="">head</code> element
1810: pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
1811: to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
1812: head</a>"<!--, otherwise, switch the <span>insertion mode</span>
1813: to "<span title="insertion mode: after head">after head</span>".-->
1.604 mike 1814: Then, <!-- in either case, --> jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li> <!-- if the
1815: head element pointer can ever be non-null when we're going through
1816: these steps, we'll need to uncomment out the commented-out bits -->
1817:
1818: <li>If <var title="">node</var> is an element from the <a href="#mathml-namespace">MathML
1819: namespace</a> or the <a href="#svg-namespace">SVG namespace</a>, then set the
1820: <var title="">foreign</var> flag to true.</li>
1.1 mike 1821:
1822: <li>If <var title="">last</var> is true, then switch the
1823: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.604 mike 1824: 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 1825:
1826: <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
1827: elements</a>.</li>
1828:
1.604 mike 1829: <li>Return to the step marked <i>loop</i>.</li>
1830:
1831: <li><i>End</i>: If <var title="">foreign</var> is true, switch the
1832: <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
1833: <a href="#insertion-mode">insertion mode</a> is set to, and switch the
1834: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
1835: foreign content">in foreign content</a>".</li>
1.1 mike 1836:
1.614 mike 1837: </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 1838:
1839: <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
1840: stack grows downwards; the topmost node on the stack is the first
1841: one added to the stack, and the bottommost node of the stack is the
1842: most recently added node in the stack (notwithstanding when the
1843: stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
1844:
1845: <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
1846: html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159 mike 1847: <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1 mike 1848: stack.</p>
1849:
1850: <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159 mike 1851: elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1 mike 1852: element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
1853: parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
1854: case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
1855: html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
1856:
1.159 mike 1857: <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 1858: node of the stack. It never gets popped off the stack.</p>
1859:
1860: <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
1861: stack.</p>
1862:
1863: <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
1864: element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
1865: 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
1866: open elements</a> (<a href="#fragment-case">fragment case</a>), then the
1867: <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159 mike 1868: of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1 mike 1869:
1870: <p>Elements in the stack fall into the following categories:</p>
1871:
1872: <dl><dt><dfn id="special">Special</dfn></dt>
1873:
1874: <dd><p>The following HTML elements have varying levels of special
1875: 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>,
1876: <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 1877: <code><a href="obsolete.html#basefont">basefont</a></code>, <code>bgsound</code>,
1.159 mike 1878: <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 1879: <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 1880: <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID--><code>datagrid</code>,
1.422 mike 1881: <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>,
1882: <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>,
1883: <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>,
1884: <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>,
1885: <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>,
1886: <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>,
1887: <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>,
1888: <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>,
1889: (commented out because this isn't an element that can end up on the
1890: stack, so it doesn't matter) --> <code><a href="text-level-semantics.html#the-img-element">img</a></code>,
1891: <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>,
1892: <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>,
1893: <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>,
1894: <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>,
1895: <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>,
1896: <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 1897: <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>,
1898: <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>,
1899: <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>,
1900: <code>wbr</code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1 mike 1901:
1902: <dt><dfn id="scoping">Scoping</dfn></dt>
1903: <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
1904: an element in scope">scopes</a> for various parts of the
1.5 mike 1905: 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 1906: <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>,
1907: <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 1908: <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's <code>foreignObject</code>.</p></dd>
1909:
1910: <dt><dfn id="formatting">Formatting</dfn></dt>
1911: <dd><p>The following HTML elements are those that end up in the
1912: <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 1913: <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>,
1914: <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>,
1915: <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>,
1916: <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
1917: <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1 mike 1918:
1919: <dt><dfn id="phrasing">Phrasing</dfn></dt>
1920: <dd><p>All other elements found while parsing an HTML
1921: document.</p></dd>
1922:
1.234 mike 1923: </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
1924: specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
1925: match state:</p>
1.1 mike 1926:
1927: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
1928: node</a> (the bottommost node of the stack).</p></li>
1929:
1930: <li><p>If <var title="">node</var> is the target node, terminate in
1931: a match state.</p></li>
1932:
1.234 mike 1933: <li><p>Otherwise, if <var title="">node</var> is one of the element
1934: types in <var title="">list</var>, terminate in a failure
1935: state.</p></li>
1.1 mike 1936:
1937: <li><p>Otherwise, set <var title="">node</var> to the previous
1938: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
1939: 2. (This will never fail, since the loop will always terminate in
1940: the previous step if the top of the stack — an
1.159 mike 1941: <code><a href="semantics.html#the-html-element-0">html</a></code> element — is reached.)</p></li>
1.1 mike 1942:
1.234 mike 1943: </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
1944: it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
1945: of the following element types:</p>
1946:
1947: <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
1948: <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
1949: <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.) -->
1950: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
1951: <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
1952: <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
1953: <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
1954: <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
1955: <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
1956: <li><code title="">foreignObject</code> in the SVG namespace</li>
1957: </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
1958: item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
1959: scope</a> consisting of the following element types:</p>
1960:
1961: <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
1962: in scope</a></i> algorithm.</li>
1963: <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
1964: <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
1965: </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
1966: scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
1967: scope</a> consisting of the following element types:</p>
1968:
1969: <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.) -->
1970: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
1971: </ul><p>Nothing happens if at any time any of the elements in the
1.1 mike 1972: <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
1973: or removed from, the <code>Document</code> tree. In particular, the
1974: stack is not changed in this situation. This can cause, amongst
1975: other strange effects, content to be appended to nodes that are no
1976: longer in the DOM.</p>
1977:
1978: <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
1979: the stack is manipulated in a random-access fashion.</p>
1980:
1981:
1.614 mike 1982: <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 1983:
1984: <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
1985: empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
1986:
1987: <p>The list contains elements in the <a href="#formatting">formatting</a>
1988: category, and scope markers. The scope markers are inserted when
1.159 mike 1989: 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 1990: elements, marquees, table cells, and table captions, and are used to
1.5 mike 1991: prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159 mike 1992: elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1 mike 1993: tables.</p>
1994:
1995: <p class="note">The scope markers are unrelated to the concept of an
1996: element being <a href="#has-an-element-in-scope" title="has an element in scope">in
1997: scope</a>.</p>
1998:
1999: <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
2000: elements</a> is associated with the token for which it was
2001: created, so that further elements can be created for that token if
2002: necessary.</p>
2003:
2004: <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
2005: active formatting elements</dfn>, the UA must perform the following
2006: steps:</p>
2007:
2008: <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
2009: elements</a>, then there is nothing to reconstruct; stop this
2010: algorithm.</li>
2011:
2012: <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
2013: active formatting elements</a> is a marker, or if it is an
2014: element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
2015: there is nothing to reconstruct; stop this algorithm.</li>
2016:
2017: <li>Let <var title="">entry</var> be the last (most recently added)
2018: element in the <a href="#list-of-active-formatting-elements">list of active formatting
2019: elements</a>.</li>
2020:
2021: <li>If there are no entries before <var title="">entry</var> in the
2022: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
2023: 8.</li>
2024:
2025: <li>Let <var title="">entry</var> be the entry one earlier than
2026: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2027: elements</a>.</li>
2028:
2029: <li>If <var title="">entry</var> is neither a marker nor an element
2030: that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
2031: 4.</li>
2032:
2033: <li>Let <var title="">entry</var> be the element one later than
2034: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2035: elements</a>.</li>
2036:
2037: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
2038: element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
2039:
2040: <li>Append <var title="">new element</var> to the <a href="#current-node">current
2041: node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
2042: elements</a> so that it is the new <a href="#current-node">current
2043: node</a>.</li>
2044:
2045: <li>Replace the entry for <var title="">entry</var> in the list
2046: with an entry for <var title="">new element</var>.</li>
2047:
2048: <li>If the entry for <var title="">new element</var> in the
2049: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
2050: entry in the list, return to step 7.</li>
2051:
2052: </ol><p>This has the effect of reopening all the formatting elements that
2053: were opened in the current body, cell, or caption (whichever is
2054: youngest) that haven't been explicitly closed.</p>
2055:
2056: <p class="note">The way this specification is written, the
2057: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
2058: elements in chronological order with the least recently added
2059: element first and the most recently added element last (except for
2060: while steps 8 to 11 of the above algorithm are being executed, of
2061: course).</p>
2062:
2063: <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
2064: active formatting elements up to the last marker</dfn>, the UA must
2065: perform the following steps:</p>
2066:
2067: <ol><li>Let <var title="">entry</var> be the last (most recently added)
2068: entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
2069:
2070: <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
2071: formatting elements</a>.</li>
2072:
2073: <li>If <var title="">entry</var> was a marker, then stop the
2074: algorithm at this point. The list has been cleared up to the last
2075: marker.</li>
2076:
2077: <li>Go to step 1.</li>
2078:
1.614 mike 2079: </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 2080:
2081: <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
2082: pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
2083: pointer</dfn> are both null.</p>
2084:
1.159 mike 2085: <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1 mike 2086: implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
2087: element pointer</a> gets set to point to this node.</p>
2088:
2089: <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
2090: points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
2091: whose end tag has not yet been seen. It is used to make form
2092: controls associate with forms in the face of dramatically bad
2093: markup, for historical reasons.</p>
2094:
2095:
1.614 mike 2096: <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 2097:
2098: <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
2099: <code>Document</code> with which the parser is associated when the
2100: parser was created, and "disabled" otherwise.</p>
2101:
2102: <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
2103: when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
2104: parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
2105: don't execute in that case.</p>
2106:
2107: <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
2108: created. It is set to "not ok" after certain tokens are seen.</p>
2109:
1.266 mike 2110: </div><div class="impl">
1.1 mike 2111:
1.159 mike 2112: <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 2113:
2114: <p>Implementations must act as if they used the following state
2115: machine to tokenize HTML. The state machine must start in the
2116: <a href="#data-state">data state</a>. Most states consume a single character,
2117: which may have various side-effects, and either switches the state
2118: machine to a new state to <em>reconsume</em> the same character, or
2119: switches it to a new state (to consume the next character), or
2120: repeats the same state (to consume the next character). Some states
2121: have more complicated behavior and can consume several characters
1.541 mike 2122: before switching to another state. In some cases, the tokenizer
2123: state is also changed by the tree construction stage.</p>
1.1 mike 2124:
1.541 mike 2125: <p>The exact behavior of certain states depends on the
2126: <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
2127: elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
2128: buffer</var></dfn> to track progress.</p>
1.1 mike 2129:
2130: <p>The output of the tokenization step is a series of zero or more
2131: of the following tokens: DOCTYPE, start tag, end tag, comment,
2132: character, end-of-file. DOCTYPE tokens have a name, a public
2133: identifier, a system identifier, and a <i>force-quirks
2134: flag</i>. When a DOCTYPE token is created, its name, public
2135: identifier, and system identifier must be marked as missing (which
2136: is a distinct state from the empty string), and the <i>force-quirks
2137: flag</i> must be set to <i>off</i> (its other state is
2138: <i>on</i>). Start and end tag tokens have a tag name, a
2139: <i>self-closing flag</i>, and a list of attributes, each of which
2140: has a name and a value. When a start or end tag token is created,
2141: its <i>self-closing flag</i> must be unset (its other state is that
2142: it be set), and its attributes list must be empty. Comment and
2143: character tokens have data.</p>
2144:
2145: <p>When a token is emitted, it must immediately be handled by the
2146: <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541 mike 2147: can affect the state of the tokenization stage, and can insert
2148: additional characters into the stream. (For example, the
1.1 mike 2149: <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159 mike 2150: using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1 mike 2151: characters into the stream being tokenized.)</p>
2152:
2153: <p>When a start tag token is emitted with its <i>self-closing
2154: flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
2155: self-closing flag">acknowledged</dfn> when it is processed by the
2156: tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
2157:
2158: <p>When an end tag token is emitted with attributes, that is a
2159: <a href="#parse-error">parse error</a>.</p>
2160:
2161: <p>When an end tag token is emitted with its <i>self-closing
2162: flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
2163:
1.541 mike 2164: <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
2165: tag name matches the tag name of the last start tag to have been
2166: emitted from this tokenizer, if any. If no start tag has been
2167: emitted from this tokenizer, then no end tag token is
2168: appropriate.</p>
2169:
1.1 mike 2170: <p>Before each step of the tokenizer, the user agent must first
2171: check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
2172: tokenizer must abort the processing of any nested invocations of the
1.479 mike 2173: tokenizer, yielding control back to the caller.</p>
1.1 mike 2174:
2175: <p>The tokenizer state machine consists of the states defined in the
2176: following subsections.</p>
2177:
1.541 mike 2178:
1.333 mike 2179: <!-- Order of the lists below is supposed to be non-error then
2180: error, by unicode, then EOF, ending with "anything else" -->
1.1 mike 2181:
1.541 mike 2182:
1.614 mike 2183: <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 2184:
2185: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2186:
2187: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.541 mike 2188: <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56 mike 2189: state</a>.</dd>
1.1 mike 2190:
1.541 mike 2191: <dt>U+003C LESS-THAN SIGN (<)</dt>
2192: <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
2193:
2194: <dt>EOF</dt>
2195: <dd>Emit an end-of-file token.</dd>
2196:
2197: <dt>Anything else</dt>
2198: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2199: token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2200:
1.618 mike 2201: </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>
2202:
2203: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2204: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2205:
2206: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2207: token.</p>
2208:
2209: <p>Otherwise, emit the character token that was returned.</p>
2210:
2211: <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
2212:
2213:
2214: <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 2215:
1.541 mike 2216: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2217:
1.541 mike 2218: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.618 mike 2219: <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541 mike 2220: state</a>.</dd>
1.1 mike 2221:
2222: <dt>U+003C LESS-THAN SIGN (<)</dt>
1.541 mike 2223: <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
2224:
2225: <dt>EOF</dt>
2226: <dd>Emit an end-of-file token.</dd>
1.1 mike 2227:
1.541 mike 2228: <dt>Anything else</dt>
2229: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2230: token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 2231:
1.618 mike 2232: </dl><h5 id="character-reference-in-rcdata-state"><span class="secno">9.2.4.4 </span><dfn>Character reference in RCDATA state</dfn></h5>
2233:
2234: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2235: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2236:
2237: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2238: token.</p>
2239:
2240: <p>Otherwise, emit the character token that was returned.</p>
2241:
2242: <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
2243:
2244:
2245: <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 2246:
1.541 mike 2247: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2248:
1.541 mike 2249: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2250: <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1 mike 2251:
2252: <dt>EOF</dt>
2253: <dd>Emit an end-of-file token.</dd>
2254:
2255: <dt>Anything else</dt>
1.541 mike 2256: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2257: token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 2258:
1.618 mike 2259: </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 2260:
1.541 mike 2261: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2262:
1.541 mike 2263: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2264: <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1 mike 2265:
1.541 mike 2266: <dt>EOF</dt>
2267: <dd>Emit an end-of-file token.</dd>
1.1 mike 2268:
1.541 mike 2269: <dt>Anything else</dt>
2270: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2271: token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2272:
1.618 mike 2273: </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 2274:
1.541 mike 2275: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2276:
1.541 mike 2277: <dl class="switch"><dt>EOF</dt>
2278: <dd>Emit an end-of-file token.</dd>
1.1 mike 2279:
1.541 mike 2280: <dt>Anything else</dt>
2281: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2282: token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1 mike 2283:
1.618 mike 2284: </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 2285:
1.541 mike 2286: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2287:
1.541 mike 2288: <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
2289: <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1 mike 2290:
1.541 mike 2291: <dt>U+002F SOLIDUS (/)</dt>
2292: <dd>Switch to the <a href="#close-tag-open-state">close tag open state</a>.</dd>
1.1 mike 2293:
1.541 mike 2294: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2295: <dd>Create a new start tag token, set its tag name to the
2296: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
2297: character's code point), then switch to the <a href="#tag-name-state">tag name
2298: state</a>. (Don't emit the token yet; further details will
2299: be filled in before it is emitted.)</dd>
1.1 mike 2300:
1.541 mike 2301: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2302: <dd>Create a new start tag token, set its tag name to the
2303: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2304: name state</a>. (Don't emit the token yet; further details will
2305: be filled in before it is emitted.)</dd>
1.1 mike 2306:
1.541 mike 2307: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2308: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2309: character token and a U+003E GREATER-THAN SIGN character
2310: token. Switch to the <a href="#data-state">data state</a>.</dd>
1.1 mike 2311:
1.541 mike 2312: <dt>U+003F QUESTION MARK (?)</dt>
2313: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2314: comment state</a>.</dd>
1.1 mike 2315:
1.541 mike 2316: <dt>Anything else</dt>
2317: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2318: character token and reconsume the <a href="#current-input-character">current input
2319: character</a> in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2320:
1.618 mike 2321: </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 2322:
1.541 mike 2323: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2324:
2325: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2326: <dd>Create a new end tag token, set its tag name to the lowercase
1.541 mike 2327: version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
2328: the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1 mike 2329: state</a>. (Don't emit the token yet; further details will be
2330: filled in before it is emitted.)</dd>
2331:
2332: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541 mike 2333: <dd>Create a new end tag token, set its tag name to the
2334: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2335: name state</a>. (Don't emit the token yet; further details will
2336: be filled in before it is emitted.)</dd>
1.1 mike 2337:
2338: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2339: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
2340: state</a>.</dd>
2341:
2342: <dt>EOF</dt>
2343: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2344: character token and a U+002F SOLIDUS character token. Reconsume
2345: the EOF character in the <a href="#data-state">data state</a>.</dd>
2346:
2347: <dt>Anything else</dt>
2348: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2349: comment state</a>.</dd>
2350:
1.618 mike 2351: </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 2352:
2353: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2354:
2355: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2356: <dt>U+000A LINE FEED (LF)</dt>
2357: <dt>U+000C FORM FEED (FF)</dt>
2358: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2359: <dt>U+0020 SPACE</dt>
2360: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
2361:
2362: <dt>U+002F SOLIDUS (/)</dt>
2363: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
2364:
2365: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2366: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
2367: state</a>.</dd>
2368:
2369: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 2370: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2371: character</a> (add 0x0020 to the character's code point) to the
2372: current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
2373: state</a>.</dd>
2374:
2375: <dt>EOF</dt>
2376: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2377: <a href="#data-state">data state</a>.</dd>
2378:
2379: <dt>Anything else</dt>
2380: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2381: tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
2382:
1.618 mike 2383: </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 2384: <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
2385:
2386: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2387:
2388: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2389: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2390: to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
2391:
2392: <dt>Anything else</dt>
2393: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2394: <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
2395: state</a>.</dd>
2396:
1.618 mike 2397: </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 2398: <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
2399:
2400: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2401:
2402: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2403: <dd>Create a new end tag token, and set its tag name to the
2404: lowercase version of the <a href="#current-input-character">current input character</a> (add
2405: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2406: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2407: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2408: the token yet; further details will be filled in before it is
2409: emitted.)</dd>
2410:
2411: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2412: <dd>Create a new end tag token, and set its tag name to the
2413: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2414: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2415: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2416: the token yet; further details will be filled in before it is
2417: emitted.)</dd>
2418:
2419: <dt>Anything else</dt>
2420: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2421: character token, and reconsume the <a href="#current-input-character">current input
2422: character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2423:
1.618 mike 2424: </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 2425: <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
2426:
2427: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2428:
2429: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2430: <dt>U+000A LINE FEED (LF)</dt>
2431: <dt>U+000C FORM FEED (FF)</dt>
2432: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2433: <dt>U+0020 SPACE</dt>
2434: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2435: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2436: state</a>. Otherwise, treat it as per the "anything else" entry
2437: below.</dd>
2438:
2439: <dt>U+002F SOLIDUS (/)</dt>
2440: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2441: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2442: state</a>. Otherwise, treat it as per the "anything else" entry
2443: below.</dd>
2444:
2445: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2446: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2447: token</a>, then emit the current tag token and switch to the
2448: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2449: else" entry below.</dd>
2450:
2451: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2452: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2453: character</a> (add 0x0020 to the character's code point) to the
2454: current tag token's tag name. Append the <a href="#current-input-character">current input
2455: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2456: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2457:
2458: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2459: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2460: tag token's tag name. Append the <a href="#current-input-character">current input
2461: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2462: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2463:
2464: <dt>Anything else</dt>
2465: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2466: character token, a character token for each of the characters in
2467: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2468: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2469: in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2470:
1.618 mike 2471: </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 2472: <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
2473:
2474: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2475:
2476: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2477: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2478: to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
2479:
2480: <dt>Anything else</dt>
2481: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2482: <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
2483: state</a>.</dd>
2484:
1.618 mike 2485: </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 2486: <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
2487:
2488: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2489:
2490: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2491: <dd>Create a new end tag token, and set its tag name to the
2492: lowercase version of the <a href="#current-input-character">current input character</a> (add
2493: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2494: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2495: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2496: the token yet; further details will be filled in before it is
2497: emitted.)</dd>
2498:
2499: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2500: <dd>Create a new end tag token, and set its tag name to the
2501: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2502: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2503: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2504: the token yet; further details will be filled in before it is
2505: emitted.)</dd>
2506:
2507: <dt>Anything else</dt>
2508: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2509: character token, and reconsume the <a href="#current-input-character">current input
2510: character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2511:
1.618 mike 2512: </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 2513: <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
2514:
2515: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2516:
2517: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2518: <dt>U+000A LINE FEED (LF)</dt>
2519: <dt>U+000C FORM FEED (FF)</dt>
2520: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2521: <dt>U+0020 SPACE</dt>
2522: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2523: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2524: state</a>. Otherwise, treat it as per the "anything else" entry
2525: below.</dd>
2526:
2527: <dt>U+002F SOLIDUS (/)</dt>
2528: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2529: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2530: state</a>. Otherwise, treat it as per the "anything else" entry
2531: below.</dd>
2532:
2533: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2534: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2535: token</a>, then emit the current tag token and switch to the
2536: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2537: else" entry below.</dd>
2538:
2539: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2540: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2541: character</a> (add 0x0020 to the character's code point) to the
2542: current tag token's tag name. Append the <a href="#current-input-character">current input
2543: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2544: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2545:
2546: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2547: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2548: tag token's tag name. Append the <a href="#current-input-character">current input
2549: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2550: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2551:
2552: <dt>Anything else</dt>
2553: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2554: character token, a character token for each of the characters in
2555: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2556: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2557: in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2558:
1.618 mike 2559: </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 2560:
2561: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2562:
2563: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2564: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2565: to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
2566:
2567: <dt>U+0021 EXCLAMATION MARK (!)</dt>
2568: <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
2569: EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
2570: escape start state</a>.</dd>
2571:
2572: <dt>Anything else</dt>
2573: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2574: <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
2575: state</a>.</dd>
2576:
1.618 mike 2577: </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 2578: <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
2579:
2580: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2581:
2582: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2583: <dd>Create a new end tag token, and set its tag name to the
2584: lowercase version of the <a href="#current-input-character">current input character</a> (add
2585: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2586: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2587: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2588: the token yet; further details will be filled in before it is
2589: emitted.)</dd>
2590:
2591: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2592: <dd>Create a new end tag token, and set its tag name to the
2593: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2594: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2595: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2596: the token yet; further details will be filled in before it is
2597: emitted.)</dd>
2598:
2599: <dt>Anything else</dt>
2600: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2601: character token, and reconsume the <a href="#current-input-character">current input
2602: character</a> in the <a href="#script-data-state">script data state</a>.</dd>
2603:
1.618 mike 2604: </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 2605: <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
2606:
2607: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2608:
2609: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2610: <dt>U+000A LINE FEED (LF)</dt>
2611: <dt>U+000C FORM FEED (FF)</dt>
2612: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2613: <dt>U+0020 SPACE</dt>
2614: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2615: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2616: state</a>. Otherwise, treat it as per the "anything else" entry
2617: below.</dd>
2618:
2619: <dt>U+002F SOLIDUS (/)</dt>
2620: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2621: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2622: state</a>. Otherwise, treat it as per the "anything else" entry
2623: below.</dd>
2624:
2625: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2626: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2627: token</a>, then emit the current tag token and switch to the
2628: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2629: else" entry below.</dd>
2630:
2631: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2632: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2633: character</a> (add 0x0020 to the character's code point) to the
2634: current tag token's tag name. Append the <a href="#current-input-character">current input
2635: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2636: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2637:
2638: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2639: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2640: tag token's tag name. Append the <a href="#current-input-character">current input
2641: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2642: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2643:
2644: <dt>Anything else</dt>
2645: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2646: character token, a character token for each of the characters in
2647: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2648: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2649: in the <a href="#script-data-state">script data state</a>.</dd>
2650:
1.618 mike 2651: </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 2652:
2653: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2654:
2655: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2656: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2657: <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
2658:
2659: <dt>Anything else</dt>
2660: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2661: <a href="#script-data-state">script data state</a>.</dd>
2662:
1.618 mike 2663: </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 2664:
2665: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2666:
2667: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2668: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2669: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2670:
2671: <dt>Anything else</dt>
2672: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2673: <a href="#script-data-state">script data state</a>.</dd>
2674:
1.618 mike 2675: </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 2676:
2677: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2678:
2679: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2680: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2681: <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
2682:
1.542 mike 2683: <dt>U+003C LESS-THAN SIGN (<)</dt>
2684: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2685: state</a>.</p></dd>
2686:
1.541 mike 2687: <dt>EOF</dt>
2688: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2689: <a href="#data-state">data state</a>.</dd>
2690:
2691: <dt>Anything else</dt>
1.542 mike 2692: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2693: token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2694:
1.618 mike 2695: </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 2696:
2697: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2698:
2699: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2700: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2701: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2702:
1.542 mike 2703: <dt>U+003C LESS-THAN SIGN (<)</dt>
2704: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2705: state</a>.</p></dd>
2706:
1.541 mike 2707: <dt>EOF</dt>
2708: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2709: <a href="#data-state">data state</a>.</dd>
2710:
2711: <dt>Anything else</dt>
1.542 mike 2712: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2713: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2714:
1.618 mike 2715: </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 2716:
2717: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2718:
2719: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2720: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
2721: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2722:
1.542 mike 2723: <dt>U+003C LESS-THAN SIGN (<)</dt>
2724: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2725: state</a>.</p></dd>
2726:
1.541 mike 2727: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2728: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
2729: <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2730:
2731: <dt>EOF</dt>
2732: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2733: <a href="#data-state">data state</a>.</dd>
2734:
2735: <dt>Anything else</dt>
1.542 mike 2736: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2737: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2738:
1.618 mike 2739: </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 2740:
2741: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2742:
2743: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2744: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2745: to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
2746:
2747: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2748: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2749: <a href="#current-input-character">current input character</a> as a character token. Set the
2750: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2751: lowercase version of the <a href="#current-input-character">current input character</a> (add
2752: 0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
2753: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2754: state</a>.</dd>
2755:
2756: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2757: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2758: <a href="#current-input-character">current input character</a> as a character token. Set the
2759: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2760: <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
2761: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2762: state</a>.</dd>
2763:
2764: <dt>Anything else</dt>
2765: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2766: <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
2767: escaped state</a>.</dd>
2768:
1.618 mike 2769: </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 2770:
2771: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2772:
2773: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2774: <dd>Create a new end tag token, and set its tag name to the
2775: lowercase version of the <a href="#current-input-character">current input character</a> (add
2776: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2777: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2778: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2779: state</a>. (Don't emit the token yet; further details will be
2780: filled in before it is emitted.)</dd>
2781:
2782: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2783: <dd>Create a new end tag token, and set its tag name to the
2784: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2785: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2786: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2787: state</a>. (Don't emit the token yet; further details will be
2788: filled in before it is emitted.)</dd>
2789:
2790: <dt>Anything else</dt>
2791: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2792: character token, and reconsume the <a href="#current-input-character">current input
2793: character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2794:
1.618 mike 2795: </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 2796:
2797: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2798:
2799: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2800: <dt>U+000A LINE FEED (LF)</dt>
2801: <dt>U+000C FORM FEED (FF)</dt>
2802: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2803: <dt>U+0020 SPACE</dt>
2804: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2805: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2806: state</a>. Otherwise, treat it as per the "anything else" entry
2807: below.</dd>
2808:
2809: <dt>U+002F SOLIDUS (/)</dt>
2810: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2811: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2812: state</a>. Otherwise, treat it as per the "anything else" entry
2813: below.</dd>
2814:
2815: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2816: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2817: token</a>, then emit the current tag token and switch to the
2818: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2819: else" entry below.</dd>
2820:
2821: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2822: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2823: character</a> (add 0x0020 to the character's code point) to the
2824: current tag token's tag name. Append the <a href="#current-input-character">current input
2825: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2826: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2827:
2828: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2829: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2830: tag token's tag name. Append the <a href="#current-input-character">current input
2831: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2832: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2833:
2834: <dt>Anything else</dt>
2835: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2836: character token, a character token for each of the characters in
2837: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2838: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2839: in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2840:
1.618 mike 2841: </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 2842:
2843: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2844:
2845: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2846: <dt>U+000A LINE FEED (LF)</dt>
2847: <dt>U+000C FORM FEED (FF)</dt>
2848: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2849: <dt>U+0020 SPACE</dt>
2850: <dt>U+002F SOLIDUS (/)</dt>
2851: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2852: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2853: 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
2854: double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
2855: data escaped state</a>.</dd>
2856:
2857: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2858: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2859: token. Append the lowercase version of the <a href="#current-input-character">current input
2860: character</a> (add 0x0020 to the character's code point) to the
2861: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
2862: escape start state</a>.</dd>
2863:
2864: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2865: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2866: token. Append the <a href="#current-input-character">current input character</a> to the
2867: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
2868: escape start state</a>.</dd>
2869:
2870: <dt>Anything else</dt>
2871: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2872: <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2873:
1.618 mike 2874: </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 2875:
2876: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2877:
2878: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2879: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2880: <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
2881:
2882: <dt>U+003C LESS-THAN SIGN (<)</dt>
2883: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2884: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2885: state</a>.</p></dd>
2886:
2887: <dt>EOF</dt>
2888: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2889: <a href="#data-state">data state</a>.</dd>
2890:
2891: <dt>Anything else</dt>
2892: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2893: token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
2894: state</a>.</dd>
2895:
1.618 mike 2896: </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 2897:
2898: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2899:
2900: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2901: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2902: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
2903:
2904: <dt>U+003C LESS-THAN SIGN (<)</dt>
2905: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2906: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2907: state</a>.</p></dd>
2908:
2909: <dt>EOF</dt>
2910: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2911: <a href="#data-state">data state</a>.</dd>
2912:
2913: <dt>Anything else</dt>
2914: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2915: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
2916: state</a>.</dd>
2917:
1.618 mike 2918: </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 2919:
2920: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2921:
2922: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2923: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
2924: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
2925:
2926: <dt>U+003C LESS-THAN SIGN (<)</dt>
2927: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
2928: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
2929: state</a>.</p></dd>
2930:
2931: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2932: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
2933: <a href="#script-data-state">script data state</a>.</dd>
2934:
2935: <dt>EOF</dt>
2936: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2937: <a href="#data-state">data state</a>.</dd>
2938:
2939: <dt>Anything else</dt>
2940: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2941: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
2942: state</a>.</dd>
2943:
1.618 mike 2944: </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 2945:
2946: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2947:
2948: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2949: <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
2950: buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
2951: double escape end state</a>.</dd>
2952:
2953: <dt>Anything else</dt>
2954: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2955: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
2956:
1.618 mike 2957: </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 2958:
2959: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2960:
2961: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2962: <dt>U+000A LINE FEED (LF)</dt>
2963: <dt>U+000C FORM FEED (FF)</dt>
2964: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2965: <dt>U+0020 SPACE</dt>
2966: <dt>U+002F SOLIDUS (/)</dt>
2967: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2968: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2969: 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
2970: escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
2971: double escaped state</a>.</dd>
2972:
2973: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2974: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2975: token. Append the lowercase version of the <a href="#current-input-character">current input
2976: character</a> (add 0x0020 to the character's code point) to the
2977: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
2978: escape end state</a>.</dd>
2979:
2980: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2981: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2982: token. Append the <a href="#current-input-character">current input character</a> to the
2983: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
2984: escape end state</a>.</dd>
2985:
2986: <dt>Anything else</dt>
2987: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2988: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1 mike 2989:
1.618 mike 2990: </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 2991:
2992: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2993:
2994: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2995: <dt>U+000A LINE FEED (LF)</dt>
2996: <dt>U+000C FORM FEED (FF)</dt>
2997: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2998: <dt>U+0020 SPACE</dt>
2999: <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3000:
3001: <dt>U+002F SOLIDUS (/)</dt>
3002: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3003:
3004: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3005: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3006: state</a>.</dd>
3007:
3008: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3009: <dd>Start a new attribute in the current tag token. Set that
3010: attribute's name to the lowercase version of the <a href="#current-input-character">current input
3011: character</a> (add 0x0020 to the character's code point), and its
3012: value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
3013: state</a>.</dd>
3014:
3015: <dt>U+0022 QUOTATION MARK (")</dt>
3016: <dt>U+0027 APOSTROPHE (')</dt>
3017: <dt>U+003C LESS-THAN SIGN (<)</dt>
3018: <dt>U+003D EQUALS SIGN (=)</dt>
3019: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3020: entry below.</dd>
3021:
3022: <dt>EOF</dt>
3023: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3024: <a href="#data-state">data state</a>.</dd>
3025:
3026: <dt>Anything else</dt>
3027: <dd>Start a new attribute in the current tag token. Set that
3028: attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
3029: the empty string. Switch to the <a href="#attribute-name-state">attribute name
3030: state</a>.</dd>
3031:
1.618 mike 3032: </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 3033:
3034: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3035:
3036: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3037: <dt>U+000A LINE FEED (LF)</dt>
3038: <dt>U+000C FORM FEED (FF)</dt>
3039: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3040: <dt>U+0020 SPACE</dt>
3041: <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3042:
3043: <dt>U+002F SOLIDUS (/)</dt>
3044: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3045:
3046: <dt>U+003D EQUALS SIGN (=)</dt>
3047: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3048:
3049: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3050: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3051: state</a>.</dd>
3052:
3053: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3054: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3055: character</a> (add 0x0020 to the character's code point) to the
3056: current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1 mike 3057: state</a>.</dd>
3058:
3059: <dt>U+0022 QUOTATION MARK (")</dt>
3060: <dt>U+0027 APOSTROPHE (')</dt>
3061: <dt>U+003C LESS-THAN SIGN (<)</dt>
3062: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3063: entry below.</dd>
3064:
3065: <dt>EOF</dt>
3066: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3067: <a href="#data-state">data state</a>.</dd>
3068:
3069: <dt>Anything else</dt>
1.541 mike 3070: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3071: attribute's name. Stay in the <a href="#attribute-name-state">attribute name
3072: state</a>.</dd>
1.1 mike 3073:
3074: </dl><p>When the user agent leaves the attribute name state (and before
3075: emitting the tag token, if appropriate), the complete attribute's
3076: name must be compared to the other attributes on the same token;
3077: if there is already an attribute on the token with the exact same
3078: name, then this is a <a href="#parse-error">parse error</a> and the new
3079: attribute must be dropped, along with the value that gets
3080: associated with it (if any).</p>
3081:
3082:
1.618 mike 3083: <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 3084:
3085: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3086:
3087: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3088: <dt>U+000A LINE FEED (LF)</dt>
3089: <dt>U+000C FORM FEED (FF)</dt>
3090: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3091: <dt>U+0020 SPACE</dt>
3092: <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3093:
3094: <dt>U+002F SOLIDUS (/)</dt>
3095: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3096:
3097: <dt>U+003D EQUALS SIGN (=)</dt>
3098: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3099:
3100: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3101: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3102: state</a>.</dd>
3103:
3104: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3105: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3106: attribute's name to the lowercase version of the <a href="#current-input-character">current
3107: input character</a> (add 0x0020 to the character's code point),
3108: and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
3109: name state</a>.</dd>
1.1 mike 3110:
3111: <dt>U+0022 QUOTATION MARK (")</dt>
3112: <dt>U+0027 APOSTROPHE (')</dt>
3113: <dt>U+003C LESS-THAN SIGN (<)</dt>
3114: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3115: entry below.</dd>
3116:
3117: <dt>EOF</dt>
3118: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3119: <a href="#data-state">data state</a>.</dd>
3120:
3121: <dt>Anything else</dt>
3122: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3123: attribute's name to the <a href="#current-input-character">current input character</a>, and
3124: its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1 mike 3125: state</a>.</dd>
3126:
1.618 mike 3127: </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 3128:
3129: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3130:
3131: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3132: <dt>U+000A LINE FEED (LF)</dt>
3133: <dt>U+000C FORM FEED (FF)</dt>
3134: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3135: <dt>U+0020 SPACE</dt>
3136: <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3137:
3138: <dt>U+0022 QUOTATION MARK (")</dt>
3139: <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
3140:
3141: <dt>U+0026 AMPERSAND (&)</dt>
3142: <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541 mike 3143: and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1 mike 3144:
3145: <dt>U+0027 APOSTROPHE (')</dt>
3146: <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
3147:
3148: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3149: <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
3150: the <a href="#data-state">data state</a>.</dd>
3151:
3152: <dt>U+003C LESS-THAN SIGN (<)</dt>
3153: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3154: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3155: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3156: entry below.</dd>
3157:
3158: <dt>EOF</dt>
3159: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3160: <a href="#data-state">data state</a>.</dd>
3161:
3162: <dt>Anything else</dt>
3163: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3164: attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
3165: state</a>.</dd>
3166:
1.618 mike 3167: </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 3168:
3169: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3170:
3171: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3172: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3173: state</a>.</dd>
3174:
3175: <dt>U+0026 AMPERSAND (&)</dt>
3176: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3177: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3178: being U+0022 QUOTATION MARK (").</dd>
3179:
3180: <dt>EOF</dt>
3181: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3182: <a href="#data-state">data state</a>.</dd>
3183:
3184: <dt>Anything else</dt>
1.541 mike 3185: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3186: attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
3187: (double-quoted) state</a>.</dd>
1.1 mike 3188:
1.618 mike 3189: </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 3190:
3191: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3192:
3193: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3194: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3195: state</a>.</dd>
3196:
3197: <dt>U+0026 AMPERSAND (&)</dt>
3198: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3199: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3200: being U+0027 APOSTROPHE (').</dd>
3201:
3202: <dt>EOF</dt>
3203: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3204: <a href="#data-state">data state</a>.</dd>
3205:
3206: <dt>Anything else</dt>
1.541 mike 3207: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3208: attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
3209: (single-quoted) state</a>.</dd>
1.1 mike 3210:
1.618 mike 3211: </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 3212:
3213: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3214:
3215: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3216: <dt>U+000A LINE FEED (LF)</dt>
3217: <dt>U+000C FORM FEED (FF)</dt>
3218: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3219: <dt>U+0020 SPACE</dt>
3220: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3221:
3222: <dt>U+0026 AMPERSAND (&)</dt>
3223: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299 mike 3224: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3225: being U+003E GREATER-THAN SIGN (>).</dd>
1.1 mike 3226:
3227: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3228: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3229: state</a>.</dd>
3230:
3231: <dt>U+0022 QUOTATION MARK (")</dt>
3232: <dt>U+0027 APOSTROPHE (')</dt>
3233: <dt>U+003C LESS-THAN SIGN (<)</dt>
3234: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3235: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3236: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3237: entry below.</dd>
3238:
3239: <dt>EOF</dt>
3240: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3241: <a href="#data-state">data state</a>.</dd>
3242:
3243: <dt>Anything else</dt>
1.541 mike 3244: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3245: attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1 mike 3246: state</a>.</dd>
3247:
1.618 mike 3248: </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 3249:
3250: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
3251:
3252: <p>If nothing is returned, append a U+0026 AMPERSAND character to
3253: the current attribute's value.</p>
3254:
3255: <p>Otherwise, append the returned character token to the current
3256: attribute's value.</p>
3257:
3258: <p>Finally, switch back to the attribute value state that you were
3259: in when were switched into this state.</p>
3260:
3261:
1.618 mike 3262: <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 3263:
3264: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3265:
3266: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3267: <dt>U+000A LINE FEED (LF)</dt>
3268: <dt>U+000C FORM FEED (FF)</dt>
3269: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3270: <dt>U+0020 SPACE</dt>
3271: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3272:
3273: <dt>U+002F SOLIDUS (/)</dt>
3274: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3275:
3276: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3277: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3278: state</a>.</dd>
3279:
3280: <dt>EOF</dt>
3281: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3282: <a href="#data-state">data state</a>.</dd>
3283:
3284: <dt>Anything else</dt>
3285: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3286: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3287:
1.618 mike 3288: </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 3289:
3290: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3291:
3292: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3293: <dd>Set the <i>self-closing flag</i> of the current tag
3294: token. Emit the current tag token. Switch to the <a href="#data-state">data
3295: state</a>.</dd>
3296:
3297: <dt>EOF</dt>
3298: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3299: <a href="#data-state">data state</a>.</dd>
3300:
3301: <dt>Anything else</dt>
3302: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3303: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3304:
1.618 mike 3305: </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 3306:
3307: <p>Consume every character up to and including the first U+003E
3308: GREATER-THAN SIGN character (>) or the end of the file (EOF),
3309: whichever comes first. Emit a comment token whose data is the
3310: concatenation of all the characters starting from and including
3311: the character that caused the state machine to switch into the
3312: bogus comment state, up to and including the character immediately
3313: before the last consumed character (i.e. up to the character just
3314: before the U+003E or EOF character). (If the comment was started
3315: by the end of the file (EOF), the token is empty.)</p>
3316:
3317: <p>Switch to the <a href="#data-state">data state</a>.</p>
3318:
3319: <p>If the end of the file was reached, reconsume the EOF
3320: character.</p>
3321:
3322:
1.618 mike 3323: <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 3324:
1.588 mike 3325: <p>If the next two characters are both U+002D HYPHEN-MINUS
3326: characters (-), consume those two characters, create a comment token
1.1 mike 3327: whose data is the empty string, and switch to the <a href="#comment-start-state">comment
3328: start state</a>.</p>
3329:
3330: <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3331: case-insensitive</a> match for the word "DOCTYPE", then consume
3332: those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
3333:
3334: <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
3335: content</a>" and the <a href="#current-node">current node</a> is not an element
3336: in the <a href="#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585 mike 3337: an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
3338: five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
3339: character before and after), then consume those characters and
3340: switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1 mike 3341:
3342: <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
3343: <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
3344: consumed, if any, is the first character that will be in the
3345: comment.</p>
3346:
3347:
1.618 mike 3348: <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 3349:
3350: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3351:
3352: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3353: <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
3354:
3355: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3356: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
3357: <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
3358: -->
3359:
3360: <dt>EOF</dt>
3361: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3362: the EOF character in the <a href="#data-state">data state</a>.</dd>
3363:
3364: <dt>Anything else</dt>
1.541 mike 3365: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3366: token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3367:
1.618 mike 3368: </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 3369:
3370: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3371:
3372: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3373: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3374:
3375: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3376: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
3377: the <a href="#data-state">data state</a>.</dd>
3378:
3379: <dt>EOF</dt>
3380: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3381: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3382: in comment end state -->
3383:
3384: <dt>Anything else</dt>
1.541 mike 3385: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3386: <a href="#current-input-character">current input character</a> to the comment token's
3387: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3388:
1.618 mike 3389: </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 3390:
3391: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3392:
3393: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3394: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
3395:
3396: <dt>EOF</dt>
3397: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3398: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3399: in comment end state -->
3400:
3401: <dt>Anything else</dt>
1.541 mike 3402: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3403: token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3404:
1.618 mike 3405: </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 3406:
3407: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3408:
3409: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3410: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3411:
3412: <dt>EOF</dt>
3413: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3414: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3415: in comment end state -->
3416:
3417: <dt>Anything else</dt>
1.541 mike 3418: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3419: <a href="#current-input-character">current input character</a> to the comment token's
3420: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3421:
1.618 mike 3422: </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 3423:
3424: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3425:
3426: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3427: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3428: state</a>.</dd>
3429:
3430: <dt>U+0009 CHARACTER TABULATION</dt>
3431: <dt>U+000A LINE FEED (LF)</dt>
3432: <dt>U+000C FORM FEED (FF)</dt>
3433: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3434: <dt>U+0020 SPACE</dt>
1.588 mike 3435: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3436: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3437: comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
3438: state</a>.</dd>
1.1 mike 3439:
3440: <dt>U+0021 EXCLAMATION MARK (!)</dt>
3441: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
3442: state</a>.</dd>
3443:
1.333 mike 3444: <dt>U+002D HYPHEN-MINUS (-)</dt>
3445: <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464 mike 3446: character (-) to the comment token's data. Stay in the
1.333 mike 3447: <a href="#comment-end-state">comment end state</a>.</dd>
3448:
1.1 mike 3449: <dt>EOF</dt>
3450: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3451: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
3452: security reasons: otherwise, hostile user could put a <script> in
3453: a comment e.g. in a blog comment and then DOS the server so that
3454: the end tag isn't read, and then the commented <script> tag would
3455: be treated as live code -->
3456:
3457: <dt>Anything else</dt>
1.588 mike 3458: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3459: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3460: comment token's data. Switch to the <a href="#comment-state">comment
3461: state</a>.</dd>
1.1 mike 3462:
1.618 mike 3463: </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 3464:
3465: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3466:
1.333 mike 3467: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588 mike 3468: <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464 mike 3469: EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1 mike 3470: to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3471:
1.333 mike 3472: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3473: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3474: state</a>.</dd>
3475:
1.1 mike 3476: <dt>EOF</dt>
3477: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3478: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3479: comment in comment end state -->
3480:
3481: <dt>Anything else</dt>
1.588 mike 3482: <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541 mike 3483: EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
3484: character</a> to the comment token's data. Switch to the
3485: <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3486:
1.618 mike 3487: </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 3488:
3489: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3490:
1.333 mike 3491: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1 mike 3492: <dt>U+000A LINE FEED (LF)</dt>
3493: <dt>U+000C FORM FEED (FF)</dt>
3494: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3495: <dt>U+0020 SPACE</dt>
1.541 mike 3496: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1 mike 3497: the <a href="#comment-end-space-state">comment end space state</a>.</dd>
3498:
1.333 mike 3499: <dt>U+002D HYPHEN-MINUS (-)</dt>
3500: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3501:
3502: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3503: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3504: state</a>.</dd>
3505:
1.1 mike 3506: <dt>EOF</dt>
3507: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3508: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3509: comment in comment end state -->
3510:
3511: <dt>Anything else</dt>
1.541 mike 3512: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1 mike 3513: to the <a href="#comment-state">comment state</a>.</dd>
3514:
1.618 mike 3515: </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 3516:
3517: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3518:
3519: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3520: <dt>U+000A LINE FEED (LF)</dt>
3521: <dt>U+000C FORM FEED (FF)</dt>
3522: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3523: <dt>U+0020 SPACE</dt>
3524: <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3525:
3526: <dt>EOF</dt>
3527: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3528: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3529: the EOF character in the <a href="#data-state">data state</a>.</dd>
3530:
3531: <dt>Anything else</dt>
1.608 mike 3532: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
3533: <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1 mike 3534:
1.618 mike 3535: </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 3536:
3537: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3538:
3539: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3540: <dt>U+000A LINE FEED (LF)</dt>
3541: <dt>U+000C FORM FEED (FF)</dt>
3542: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3543: <dt>U+0020 SPACE</dt>
3544: <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3545:
3546: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3547: <dd>Create a new DOCTYPE token. Set the token's name to the
1.541 mike 3548: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1 mike 3549: character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
3550: state</a>.</dd>
3551:
1.333 mike 3552: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3553: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3554: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
3555: the <a href="#data-state">data state</a>.</dd>
3556:
1.1 mike 3557: <dt>EOF</dt>
3558: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3559: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3560: the EOF character in the <a href="#data-state">data state</a>.</dd>
3561:
3562: <dt>Anything else</dt>
3563: <dd>Create a new DOCTYPE token. Set the token's name to the
3564: <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
3565: state</a>.</dd>
3566:
1.618 mike 3567: </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 3568:
3569: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3570:
3571: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3572: <dt>U+000A LINE FEED (LF)</dt>
3573: <dt>U+000C FORM FEED (FF)</dt>
3574: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3575: <dt>U+0020 SPACE</dt>
3576: <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3577:
3578: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3579: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3580: state</a>.</dd>
3581:
3582: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3583: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3584: character</a> (add 0x0020 to the character's code point) to the
3585: current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3586: state</a>.</dd>
1.1 mike 3587:
3588: <dt>EOF</dt>
3589: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3590: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3591: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3592:
3593: <dt>Anything else</dt>
1.541 mike 3594: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3595: DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3596: state</a>.</dd>
1.1 mike 3597:
1.618 mike 3598: </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 3599:
3600: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3601:
3602: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3603: <dt>U+000A LINE FEED (LF)</dt>
3604: <dt>U+000C FORM FEED (FF)</dt>
3605: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3606: <dt>U+0020 SPACE</dt>
3607: <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3608:
3609: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3610: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3611: state</a>.</dd>
3612:
3613: <dt>EOF</dt>
3614: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3615: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3616: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3617:
3618: <dt>Anything else</dt>
3619: <dd>
3620:
3621: <p>If the six characters starting from the <a href="#current-input-character">current input
3622: character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
3623: for the word "PUBLIC", then consume those characters and switch to
1.444 mike 3624: the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1 mike 3625:
3626: <p>Otherwise, if the six characters starting from the
3627: <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3628: case-insensitive</a> match for the word "SYSTEM", then consume
1.444 mike 3629: those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
3630: keyword state</a>.</p>
1.1 mike 3631:
3632: <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
3633: DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
3634: the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
3635:
3636: </dd>
3637:
1.618 mike 3638: </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 3639:
3640: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3641:
3642: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3643: <dt>U+000A LINE FEED (LF)</dt>
3644: <dt>U+000C FORM FEED (FF)</dt>
3645: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3646: <dt>U+0020 SPACE</dt>
3647: <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
3648: state</a>.</dd>
3649:
1.620 mike 3650: <dt>U+0022 QUOTATION MARK (")</dt>
3651: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3652: identifier to the empty string (not missing), then switch to the
3653: <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
3654:
3655: <dt>U+0027 APOSTROPHE (')</dt>
3656: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3657: identifier to the empty string (not missing), then switch to the
3658: <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
3659:
3660: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3661: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3662: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3663: token. Switch to the <a href="#data-state">data state</a>.</dd>
3664:
1.444 mike 3665: <dt>EOF</dt>
3666: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3667: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3668: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3669:
3670: <dt>Anything else</dt>
1.620 mike 3671: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3672: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3673: DOCTYPE state</a>.</dd>
1.444 mike 3674:
1.618 mike 3675: </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 3676:
3677: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3678:
3679: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3680: <dt>U+000A LINE FEED (LF)</dt>
3681: <dt>U+000C FORM FEED (FF)</dt>
3682: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3683: <dt>U+0020 SPACE</dt>
3684: <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
3685:
3686: <dt>U+0022 QUOTATION MARK (")</dt>
3687: <dd>Set the DOCTYPE token's public identifier to the empty string
3688: (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
3689: (double-quoted) state</a>.</dd>
3690:
3691: <dt>U+0027 APOSTROPHE (')</dt>
3692: <dd>Set the DOCTYPE token's public identifier to the empty string
3693: (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
3694: (single-quoted) state</a>.</dd>
3695:
3696: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3697: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3698: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3699: token. Switch to the <a href="#data-state">data state</a>.</dd>
3700:
3701: <dt>EOF</dt>
3702: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3703: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3704: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3705:
3706: <dt>Anything else</dt>
3707: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3708: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3709: DOCTYPE state</a>.</dd>
3710:
1.618 mike 3711: </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 3712:
3713: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3714:
3715: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3716: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3717:
3718: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3719: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3720: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3721: token. Switch to the <a href="#data-state">data state</a>.</dd>
3722:
3723: <dt>EOF</dt>
3724: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3725: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3726: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3727:
3728: <dt>Anything else</dt>
3729: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3730: token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
3731: identifier (double-quoted) state</a>.</dd>
3732:
1.618 mike 3733: </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 3734:
3735: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3736:
3737: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3738: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3739:
3740: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3741: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3742: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3743: token. Switch to the <a href="#data-state">data state</a>.</dd>
3744:
3745: <dt>EOF</dt>
3746: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3747: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3748: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3749:
3750: <dt>Anything else</dt>
3751: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3752: token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
3753: identifier (single-quoted) state</a>.</dd>
3754:
1.618 mike 3755: </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 3756:
3757: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3758:
3759: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3760: <dt>U+000A LINE FEED (LF)</dt>
3761: <dt>U+000C FORM FEED (FF)</dt>
3762: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3763: <dt>U+0020 SPACE</dt>
1.541 mike 3764: <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
3765: identifiers state</a>.</dd>
1.444 mike 3766:
3767: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3768: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3769: state</a>.</dd>
3770:
3771: <dt>U+0022 QUOTATION MARK (")</dt>
3772: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3773: identifier to the empty string (not missing), then switch to the
3774: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3775:
3776: <dt>U+0027 APOSTROPHE (')</dt>
3777: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3778: identifier to the empty string (not missing), then switch to the
3779: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3780:
3781: <dt>EOF</dt>
3782: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3783: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3784: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3785:
3786: <dt>Anything else</dt>
3787: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3788: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3789: DOCTYPE state</a>.</dd>
3790:
1.618 mike 3791: </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 3792:
3793: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3794:
3795: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3796: <dt>U+000A LINE FEED (LF)</dt>
3797: <dt>U+000C FORM FEED (FF)</dt>
3798: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3799: <dt>U+0020 SPACE</dt>
1.541 mike 3800: <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
3801: state</a>.</dd>
1.444 mike 3802:
3803: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3804: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3805: state</a>.</dd>
1.1 mike 3806:
3807: <dt>U+0022 QUOTATION MARK (")</dt>
3808: <dd>Set the DOCTYPE token's system identifier to the empty string
3809: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3810: (double-quoted) state</a>.</dd>
3811:
3812: <dt>U+0027 APOSTROPHE (')</dt>
3813: <dd>Set the DOCTYPE token's system identifier to the empty string
3814: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3815: (single-quoted) state</a>.</dd>
3816:
3817: <dt>EOF</dt>
3818: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3819: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3820: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3821:
3822: <dt>Anything else</dt>
3823: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3824: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3825: DOCTYPE state</a>.</dd>
3826:
1.618 mike 3827: </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 3828:
3829: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3830:
3831: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3832: <dt>U+000A LINE FEED (LF)</dt>
3833: <dt>U+000C FORM FEED (FF)</dt>
3834: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3835: <dt>U+0020 SPACE</dt>
3836: <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
3837: state</a>.</dd>
3838:
1.620 mike 3839: <dt>U+0022 QUOTATION MARK (")</dt>
3840: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3841: identifier to the empty string (not missing), then switch to the
3842: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3843:
3844: <dt>U+0027 APOSTROPHE (')</dt>
3845: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3846: identifier to the empty string (not missing), then switch to the
3847: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3848:
3849: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3850: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3851: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3852: token. Switch to the <a href="#data-state">data state</a>.</dd>
3853:
1.444 mike 3854: <dt>EOF</dt>
3855: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3856: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3857: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3858:
3859: <dt>Anything else</dt>
1.620 mike 3860: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3861: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3862: DOCTYPE state</a>.</dd>
1.444 mike 3863:
1.618 mike 3864: </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 3865:
3866: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3867:
3868: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3869: <dt>U+000A LINE FEED (LF)</dt>
3870: <dt>U+000C FORM FEED (FF)</dt>
3871: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3872: <dt>U+0020 SPACE</dt>
3873: <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
3874:
3875: <dt>U+0022 QUOTATION MARK (")</dt>
3876: <dd>Set the DOCTYPE token's system identifier to the empty string
3877: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3878: (double-quoted) state</a>.</dd>
3879:
3880: <dt>U+0027 APOSTROPHE (')</dt>
3881: <dd>Set the DOCTYPE token's system identifier to the empty string
3882: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3883: (single-quoted) state</a>.</dd>
3884:
3885: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3886: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3887: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3888: token. Switch to the <a href="#data-state">data state</a>.</dd>
3889:
3890: <dt>EOF</dt>
3891: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3892: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3893: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3894:
3895: <dt>Anything else</dt>
3896: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3897: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3898: DOCTYPE state</a>.</dd>
3899:
1.618 mike 3900: </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 3901:
3902: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3903:
3904: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541 mike 3905: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
3906: state</a>.</dd>
1.1 mike 3907:
3908: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3909: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3910: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3911: token. Switch to the <a href="#data-state">data state</a>.</dd>
3912:
3913: <dt>EOF</dt>
3914: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3915: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3916: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3917:
3918: <dt>Anything else</dt>
1.541 mike 3919: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3920: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1 mike 3921: identifier (double-quoted) state</a>.</dd>
3922:
1.618 mike 3923: </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 3924:
3925: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3926:
3927: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541 mike 3928: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
3929: state</a>.</dd>
1.1 mike 3930:
3931: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3932: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3933: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3934: token. Switch to the <a href="#data-state">data state</a>.</dd>
3935:
3936: <dt>EOF</dt>
3937: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3938: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3939: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3940:
3941: <dt>Anything else</dt>
1.541 mike 3942: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3943: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1 mike 3944: identifier (single-quoted) state</a>.</dd>
3945:
1.618 mike 3946: </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 3947:
3948: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3949:
3950: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3951: <dt>U+000A LINE FEED (LF)</dt>
3952: <dt>U+000C FORM FEED (FF)</dt>
3953: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3954: <dt>U+0020 SPACE</dt>
1.541 mike 3955: <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
3956: state</a>.</dd>
1.1 mike 3957:
3958: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3959: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3960: state</a>.</dd>
3961:
3962: <dt>EOF</dt>
3963: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3964: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3965: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3966:
3967: <dt>Anything else</dt>
3968: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
3969: state</a>. (This does <em>not</em> set the DOCTYPE token's
3970: <i>force-quirks flag</i> to <i>on</i>.)</dd>
3971:
1.618 mike 3972: </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 3973:
3974: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3975:
3976: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3977: <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
3978: state</a>.</dd>
3979:
3980: <dt>EOF</dt>
3981: <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
3982: <a href="#data-state">data state</a>.</dd>
3983:
3984: <dt>Anything else</dt>
3985: <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
3986:
1.618 mike 3987: </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 3988:
3989: <p>Consume every character up to the next occurrence of the three
3990: character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
3991: BRACKET U+003E GREATER-THAN SIGN (<code title="">]]></code>), or the
3992: end of the file (EOF), whichever comes first. Emit a series of
3993: character tokens consisting of all the characters consumed except
3994: the matching three character sequence at the end (if one was found
3995: before the end of the file).</p>
3996:
3997: <p>Switch to the <a href="#data-state">data state</a>.</p>
3998:
3999: <p>If the end of the file was reached, reconsume the EOF
4000: character.</p>
4001:
4002:
4003:
1.618 mike 4004: <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 4005:
4006: <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
4007: reference</dfn>. This definition is used when parsing character
1.299 mike 4008: references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1 mike 4009: text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
4010: state">in attributes</a>.</p>
4011:
4012: <p>The behavior depends on the identity of the next character (the
4013: one immediately after the U+0026 AMPERSAND character):</p>
4014:
4015: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4016: <dt>U+000A LINE FEED (LF)</dt>
4017: <dt>U+000C FORM FEED (FF)</dt>
4018: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4019: <dt>U+0020 SPACE</dt>
4020: <dt>U+003C LESS-THAN SIGN</dt>
4021: <dt>U+0026 AMPERSAND</dt>
4022: <dt>EOF</dt>
4023: <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
4024:
4025: <dd>Not a character reference. No characters are consumed, and
4026: nothing is returned. (This is not an error, either.)</dd>
4027:
4028:
4029: <dt>U+0023 NUMBER SIGN (#)</dt>
4030:
4031: <dd>
4032:
4033: <p>Consume the U+0023 NUMBER SIGN.</p>
4034:
4035: <p>The behavior further depends on the character after the U+0023
4036: NUMBER SIGN:</p>
4037:
4038: <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
4039: <dt>U+0058 LATIN CAPITAL LETTER X</dt>
4040:
4041: <dd>
4042:
4043: <p>Consume the X.</p>
4044:
4045: <p>Follow the steps below, but using the range of characters
1.464 mike 4046: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
4047: SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
4048: CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
4049: words, 0-9, A-F, a-f).</p>
1.1 mike 4050:
4051: <p>When it comes to interpreting the number, interpret it as a
4052: hexadecimal number.</p>
4053:
4054: </dd>
4055:
4056:
4057: <dt>Anything else</dt>
4058:
4059: <dd>
4060:
4061: <p>Follow the steps below, but using the range of characters
1.464 mike 4062: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1 mike 4063:
4064: <p>When it comes to interpreting the number, interpret it as a
4065: decimal number.</p>
4066:
4067: </dd>
4068:
4069: </dl><p>Consume as many characters as match the range of characters
4070: given above.</p>
4071:
4072: <p>If no characters match the range, then don't consume any
4073: characters (and unconsume the U+0023 NUMBER SIGN character and, if
4074: appropriate, the X character). This is a <a href="#parse-error">parse
4075: error</a>; nothing is returned.</p>
4076:
4077: <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
4078: that too. If it isn't, there is a <a href="#parse-error">parse
4079: error</a>.</p>
4080:
4081: <p>If one or more characters match the range, then take them all
4082: and interpret the string of characters as a number (either
4083: hexadecimal or decimal as appropriate).</p>
4084:
4085: <p>If that number is one of the numbers in the first column of the
4086: following table, then this is a <a href="#parse-error">parse error</a>. Find the
4087: row with that number in the first column, and return a character
4088: token for the Unicode character given in the second column of that
4089: row.</p>
4090:
4091: <table><thead><tr><th>Number </th><th colspan="2">Unicode character
4092: </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
4093: </td></tr><tr><td>0x0D </td><td>U+000A </td><td>LINE FEED (LF)
1.464 mike 4094: </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (€)
1.1 mike 4095: </td></tr><tr><td>0x81 </td><td>U+0081 </td><td><control>
1.464 mike 4096: </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (‚)
4097: </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (ƒ)
4098: </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK („)
4099: </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (…)
4100: </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (†)
4101: </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (‡)
4102: </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
4103: </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (‰)
4104: </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (Š)
4105: </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
4106: </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (Œ)
1.1 mike 4107: </td></tr><tr><td>0x8D </td><td>U+008D </td><td><control>
1.464 mike 4108: </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
1.1 mike 4109: </td></tr><tr><td>0x8F </td><td>U+008F </td><td><control>
4110: </td></tr><tr><td>0x90 </td><td>U+0090 </td><td><control>
1.464 mike 4111: </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (‘)
4112: </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (’)
4113: </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (“)
4114: </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (”)
4115: </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (•)
4116: </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (–)
4117: </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (—)
4118: </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (˜)
4119: </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (™)
4120: </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (š)
4121: </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
4122: </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (œ)
1.1 mike 4123: </td></tr><tr><td>0x9D </td><td>U+009D </td><td><control>
1.464 mike 4124: </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (ž)
4125: </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
1.315 mike 4126: </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
4127: surrogates not allowed; see the comment in the "preprocessing the
4128: input stream" section for details --> or is greater than 0x10FFFF,
4129: then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
4130: REPLACEMENT CHARACTER.</p>
1.18 mike 4131:
4132: <p>Otherwise, return a character token for the Unicode character
1.1 mike 4133: whose code point is that number.
4134:
4135: <!-- this is the same as the equivalent list in the input stream
4136: section -->
4137: If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
4138: allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
4139: allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315 mike 4140: 0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
4141: 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
4142: 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
4143: 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
4144: 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
4145: 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
4146: 0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
4147: error</a>.</p>
1.1 mike 4148:
4149: </dd>
4150:
4151:
4152: <dt>Anything else</dt>
4153:
4154: <dd>
4155:
4156: <p>Consume the maximum number of characters possible, with the
4157: consumed characters matching one of the identifiers in the first
4158: column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
4159: <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
4160:
4161: <p>If no match can be made, then this is a <a href="#parse-error">parse
4162: error</a>. No characters are consumed, and nothing is
4163: returned.</p>
4164:
1.588 mike 4165: <p>If the last character matched is not a U+003B SEMICOLON
4166: character (;), there is a <a href="#parse-error">parse error</a>.</p>
1.1 mike 4167:
4168: <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
4169: attribute</a>, and the last character matched is not a U+003B
1.588 mike 4170: SEMICOLON character (;), and the next character is in the range
4171: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
4172: CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN
4173: SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for
4174: historical reasons, all the characters that were matched after the
4175: U+0026 AMPERSAND character (&) must be unconsumed, and nothing
4176: is returned.</p>
1.1 mike 4177:
4178: <p>Otherwise, return a character token for the character
4179: corresponding to the character reference name (as given by the
4180: second column of the <a href="named-character-references.html#named-character-references">named character references</a>
4181: table).</p>
4182:
4183: <div class="example">
4184:
4185: <p>If the markup contains <code title="">I'm &notit; I tell
4186: you</code>, the character reference is parsed as "not", as in,
4187: <code title="">I'm ¬it; I tell you</code>. But if the markup
4188: was <code title="">I'm &notin; I tell you</code>, the
4189: character reference would be parsed as "notin;", resulting in
4190: <code title="">I'm ∉ I tell you</code>.</p>
4191:
4192: </div>
4193:
4194: </dd>
4195:
1.266 mike 4196: </dl></div><div class="impl">
4197:
1.363 mike 4198: <!-- v2: One thing that this doesn't define is handling deeply
4199: nested documents. There are compatibility requirements around that:
4200: you can't throw away the elements altogether, consider Tux made only
4201: with opening <font> elements, one per character. Seems that the best
4202: thing to do is to close some formatting elements from the middle of
4203: the stack when you hit a limit, or something. -->
4204:
1.614 mike 4205: <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 4206:
4207: <p>The input to the tree construction stage is a sequence of tokens
4208: from the <a href="#tokenization">tokenization</a> stage. The tree construction
4209: stage is associated with a DOM <code>Document</code> object when a
4210: parser is created. The "output" of this stage consists of
4211: dynamically modifying or extending that document's DOM tree.</p>
4212:
4213: <p>This specification does not define when an interactive user agent
4214: has to render the <code>Document</code> so that it is available to
4215: the user, or when it has to begin accepting user input.</p>
4216:
4217: <p>As each token is emitted from the tokenizer, the user agent must
4218: process the token according to the rules given in the section
4219: corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
4220:
4221: <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
4222: character</dfn> into a node, if that node has a child immediately
4223: before where the character is to be inserted, and that child is a
4224: <code>Text</code> node, and that <code>Text</code> node was the last
4225: node that the parser inserted into the document, then the character
4226: must be appended to that <code>Text</code> node; otherwise, a new
4227: <code>Text</code> node whose data is just that character must be
4228: inserted in the appropriate place.</p>
4229:
4230: <div class="example">
4231:
4232: <p>Here are some sample inputs to the parser and the corresponding
4233: number of text nodes that they result in, assuming a user agent
4234: that executes scripts.</p>
4235:
4236: <table><thead><tr><th>Input </th><th>Number of text nodes
4237: </th></tr></thead><tbody><tr><td><pre>A<script>
4238: var script = document.getElementsByTagName('script')[0];
4239: document.body.removeChild(script);
4240: </script>B</pre>
4241: </td><td>Two adjacent text nodes in the document, containing "A" and "B".
4242: </td></tr><tr><td><pre>A<script>
4243: var text = document.createTextNode('B');
4244: document.body.appendChild(text);
4245: </script>C</pre>
4246: </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
4247: </td></tr><tr><td><pre>A<script>
4248: var text = document.getElementsByTagName('script')[0].firstChild;
4249: text.data = 'B';
4250: document.body.appendChild(text);
4251: </script>B</pre>
4252: </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
4253: </td></tr><tr><td><pre>A<table>B<tr>C</tr>C</table></pre>
4254: </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>.)
4255: </td></tr><tr><td><pre>A<table><tr> B</tr> B</table></pre>
4256: </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>.)
4257: </td></tr><tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
4258: </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.)
4259: </td></tr></tbody></table></div>
4260:
4261: <p id="mutation-during-parsing">DOM mutation events must not fire
4262: for changes caused by the UA parsing the document. (Conceptually,
4263: the parser is not mutating the DOM, it is constructing it.) This
1.159 mike 4264: 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 4265:
4266: <p class="note">Not all of the tag names mentioned below are
4267: conformant tag names in this specification; many are included to
4268: handle legacy content. They still form part of the algorithm that
4269: implementations are required to implement to claim conformance.</p>
4270:
4271: <p class="note">The algorithm described below places no limit on the
4272: depth of the DOM tree generated, or on the length of tag names,
4273: attribute names, attribute values, text nodes, etc. While
4274: implementors are encouraged to avoid arbitrary limits, it is
4275: recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445 mike 4276: concerns</a> will likely force user agents to impose nesting depth
4277: constraints.</p>
1.1 mike 4278:
4279:
1.614 mike 4280: <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 4281:
4282: <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
4283: element for the token">create an element for a token</dfn> in a
4284: particular namespace, the UA must create a node implementing the
4285: interface appropriate for the element type corresponding to the tag
4286: name of the token in the given namespace (as given in the
4287: specification that defines that element, e.g. for an <code><a href="text-level-semantics.html#the-a-element">a</a></code>
4288: element in the <a href="#html-namespace-0">HTML namespace</a>, this specification
4289: defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
4290: the tag name being the name of that element, with the node being in
4291: the given namespace, and with the attributes on the node being those
4292: given in the given token.</p>
4293:
4294: <p>The interface appropriate for an element in the <a href="#html-namespace-0">HTML
1.426 mike 4295: namespace</a> that is not defined in this specification (or
4296: <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44 mike 4297: <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1 mike 4298: interface is not defined by that namespace's specification must use
4299: the interface <code>Element</code>.</p>
4300:
4301: <p>When a <a href="forms.html#category-reset" title="category-reset">resettable</a> element is
4302: created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
4303: invoked once the attributes are set. (This initializes the element's
4304: <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
4305: attributes.)</p>
4306:
4307: <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
4308: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
4309: for the token</a> in the <a href="#html-namespace-0">HTML namespace</a>, and then
4310: append this node to the <a href="#current-node">current node</a>, and push it onto
4311: the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
4312: <a href="#current-node">current node</a>.</p>
4313:
4314: <p>The steps below may also require that the UA insert an HTML
4315: element in a particular place, in which case the UA must follow the
4316: same steps except that it must insert or append the new node in the
4317: location specified instead of appending it to the <a href="#current-node">current
4318: node</a>. (This happens in particular during the parsing of
4319: tables with invalid content.)</p>
4320:
4321: <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
4322: algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
4323: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
4324: 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
4325: <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
4326: created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
4327: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
4328: inserting it wherever it is to be inserted.</p>
4329:
4330: <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
4331: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
4332: for the token</a> in the given namespace, and then append this
4333: node to the <a href="#current-node">current node</a>, and push it onto the
4334: <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
4335: <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>
4336: whose value is not exactly the same as the element's namespace, that
4337: is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
4338: element has an <code title="">xmlns:xlink</code> attribute in the
4339: <a href="#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="#xlink-namespace">XLink
4340: Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
4341:
4342: <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
4343: attributes</dfn> for a token, then, if the token has an attribute
4344: named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
4345:
4346: <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
4347: attributes</dfn> for a token, then, for each attribute on the token
4348: whose attribute name is one of the ones in the first column of the
4349: following table, change the attribute's name to the name given in
4350: the corresponding cell in the second column. (This fixes the case of
4351: SVG attributes that are not all lowercase.)</p>
4352:
4353: <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
4354: </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
4355: </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
4356: </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
4357: </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
4358: </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
4359: </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
4360: </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
4361: </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
4362: </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
4363: </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
4364: </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
4365: </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
4366: </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
4367: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
4368: </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
4369: </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
4370: </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
4371: </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
4372: </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
4373: </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
4374: </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
4375: </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
4376: </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
4377: </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
4378: </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
4379: </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
4380: </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
4381: </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
4382: </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
4383: </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
4384: </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
4385: </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
4386: </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
4387: </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
4388: </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
4389: </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
4390: </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
4391: </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
4392: </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
4393: </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
4394: </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
4395: </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
4396: </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
4397: </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
4398: </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
4399: </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
4400: </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
4401: </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
4402: </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
4403: </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
4404: </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
4405: </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
4406: </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
4407: </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
4408: </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
4409: </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
4410: </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
4411: </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
4412: </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
4413: </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
4414: </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
4415: </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
4416: </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
4417: foreign attributes</dfn> for a token, then, if any of the attributes
4418: on the token match the strings given in the first column of the
4419: following table, let the attribute be a namespaced attribute, with
4420: the prefix being the string given in the corresponding cell in the
4421: second column, the local name being the string given in the
4422: corresponding cell in the third column, and the namespace being the
4423: namespace given in the corresponding cell in the fourth
4424: column. (This fixes the use of namespaced attributes, in particular
4425: <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
4426: the <span>XML namespace</span></a>.)</p>
4427:
4428: <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
4429: </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>
4430: </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>
4431: </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>
4432: </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>
4433: </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>
4434: </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>
4435: </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>
4436: </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 -->
4437: </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>
4438: </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>
4439: </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>
4440: </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 4441: </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 4442: <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
4443: following steps. These algorithms are always invoked in response to
4444: a start tag token.</p>
4445:
4446: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
4447:
1.91 mike 4448: <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541 mike 4449: text element parsing algorithm</a>, switch the tokenizer to the
4450: <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
4451: was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
4452: switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1 mike 4453:
4454: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
4455: <a href="#insertion-mode">insertion mode</a>.</p>
4456:
1.540 mike 4457: </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 4458:
1.614 mike 4459: </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 4460:
4461: <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
4462: tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422 mike 4463: <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 4464: <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
4465: <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
4466: <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
4467: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4468: elements</a>.</p>
4469:
4470: <p>If a step requires the UA to generate implied end tags but lists
4471: an element to exclude from the process, then the UA must perform the
4472: above steps as if that element was not in the above list.</p>
4473:
4474:
1.614 mike 4475: <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 4476:
4477: <p>Foster parenting happens when content is misnested in tables.</p>
4478:
4479: <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
4480: parent">foster parented</dfn>, the node <var title="">node</var>
4481: must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4482:
4483: <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
4484: 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
4485: elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
4486: such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4487: the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
4488: case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
4489: element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159 mike 4490: <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1 mike 4491: <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
4492: elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4493: <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
4494: node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
4495: the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4496: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
4497:
4498: <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
4499: 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
4500: elements</a>, then <var title="">node</var> must be inserted
4501: immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4502: the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
4503: element</a></i>; otherwise, <var title="">node</var> must be
4504: <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4505:
4506:
4507:
1.614 mike 4508: <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 4509:
4510: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
4511: mode: initial">initial</a>", tokens must be handled as follows:</p>
4512:
4513: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4514: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4515: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4516: <dd>
4517: <p>Ignore the token.</p>
4518: </dd>
4519:
4520: <dt>A comment token</dt>
4521: <dd>
4522: <p>Append a <code>Comment</code> node to the <code>Document</code>
4523: object with the <code title="">data</code> attribute set to the
4524: data given in the comment token.</p>
4525: </dd>
4526:
4527: <dt>A DOCTYPE token</dt>
4528: <dd>
4529:
4530: <p>If the DOCTYPE token's name is not a
4531: <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
4532: missing, or the token's system identifier is neither missing nor a
4533: <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465 mike 4534: "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1 mike 4535: conditions in the following list are matched, then there is a
4536: <a href="#parse-error">parse error</a>. If one of the sets of conditions in the
4537: following list is matched, then there is an <dfn id="obsolete-permitted-doctype">obsolete
4538: permitted DOCTYPE</dfn>.</p>
4539:
4540: <ul><!-- only things that trigger no-quirks mode and were valid in
4541: 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 4542: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4543: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD HTML 4.0//EN</code>", and the
4544: token's system identifier is either missing or the
4545: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
4546:
4547: <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98 mike 4548: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4549: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD HTML 4.01//EN</code>", and the
4550: token's system identifier is either missing or the
4551: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
4552:
4553: <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98 mike 4554: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4555: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>",
4556: and the token's system identifier is the
4557: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
4558:
4559: <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98 mike 4560: case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1 mike 4561: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD XHTML 1.1//EN</code>", and the
4562: token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4563: string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
4564:
4565: </ul><p>Conformance checkers may, based on the values (including
4566: presence or lack thereof) of the DOCTYPE token's name, public
4567: identifier, or system identifier, switch to a conformance checking
4568: mode for another language (e.g. based on the DOCTYPE token a
4569: conformance checker could recognize that the document is an
1.183 mike 4570: HTML4-era document, and defer to an HTML4 conformance
1.1 mike 4571: checker.)</p>
4572:
4573: <p>Append a <code>DocumentType</code> node to the
4574: <code>Document</code> node, with the <code title="">name</code>
4575: attribute set to the name given in the DOCTYPE token, or the empty
4576: string if the name was missing; the <code title="">publicId</code>
4577: attribute set to the public identifier given in the DOCTYPE token,
4578: or the empty string if the public identifier was missing; the
4579: <code title="">systemId</code> attribute set to the system
4580: identifier given in the DOCTYPE token, or the empty string if the
4581: system identifier was missing; and the other attributes specific
4582: to <code>DocumentType</code> objects set to null and empty lists
4583: as appropriate. Associate the <code>DocumentType</code> node with
4584: the <code>Document</code> object so that it is returned as the
4585: value of the <code title="">doctype</code> attribute of the
4586: <code>Document</code> object.</p>
4587:
4588: <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
4589: one of the conditions in the following list, then set the
4590: <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
4591:
4592: <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
4593: <li> The name is set to anything other than "<code title="">HTML</code>". </li>
4594: <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
4595: <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4596: <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4597: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
4598: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
4599: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
4600: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
4601: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
4602: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
4603: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
4604: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
4605: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
4606: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4607: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
4608: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
4609: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
4610: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
4611: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
4612: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
4613: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
4614: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
4615: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
4616: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
4617: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
4618: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
4619: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
4620: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
4621: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
4622: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
4623: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
4624: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
4625: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
4626: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
4627: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
4628: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
4629: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
4630: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
4631: <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
4632: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
4633: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
4634: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
4635: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
4636: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
4637: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
4638: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
4639: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
4640: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
4641: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
4642: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
4643: <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
4644: <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
4645: <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
4646: <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
4647: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
4648: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
4649: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
4650: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
4651: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4652: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
4653: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
4654: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
4655: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
4656: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
4657: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
4658: <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
4659: <li> The public identifier starts with: "<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 3.0//EN//</code>" </li>-->
4661: <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
4662: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
4663: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
4664: <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
4665: <li> The public identifier is set to: "<code title="">HTML</code>" </li>
4666: <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
4667: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4668: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
4669: </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
4670: in the following list, then set the <code>Document</code> to
4671: <a href="dom.html#limited-quirks-mode">limited quirks mode</a>:</p>
4672:
4673: <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
4674: <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
4675: <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4676: <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
4677: </ul><p>The name, system identifier, and public identifier strings must
4678: be compared to the values given in the lists above in an
4679: <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> manner. A system identifier
4680: whose value is the empty string is not considered missing for the
4681: purposes of the conditions above.</p>
4682:
4683: <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>
4684:
4685: </dd>
4686:
4687: <dt>Anything else</dt>
4688: <dd>
4689:
4690: <p><a href="#parse-error">Parse error</a>.</p>
4691:
4692: <p>Set the <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
4693:
4694: <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
4695: reprocess the current token.</p>
4696:
4697: </dd>
4698:
1.614 mike 4699: </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 4700:
4701: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
4702: mode: before html">before html</a>", tokens must be handled as follows:</p>
4703:
4704: <dl class="switch"><dt>A DOCTYPE token</dt>
4705: <dd>
4706: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4707: </dd>
4708:
4709: <dt>A comment token</dt>
4710: <dd>
4711: <p>Append a <code>Comment</code> node to the <code>Document</code>
4712: object with the <code title="">data</code> attribute set to the
4713: data given in the comment token.</p>
4714: </dd>
4715:
4716: <dt>A character token that is one of U+0009 CHARACTER
4717: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4718: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4719: <dd>
4720: <p>Ignore the token.</p>
4721: </dd>
4722:
4723: <dt>A start tag whose tag name is "html"</dt>
4724: <dd>
4725:
4726: <p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the <a href="#html-namespace-0">HTML
4727: namespace</a>. Append it to the <code>Document</code>
4728: object. Put this element in the <a href="#stack-of-open-elements">stack of open
4729: elements</a>.</p>
4730:
4731: <p id="parser-appcache">If the <code>Document</code> is being
4732: loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
4733: <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
4734: has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute,
4735: then <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolve</a> the value of that
4736: attribute to an <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly
4737: 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 4738: algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
4739: any <a href="infrastructure.html#url-fragment" title="url-fragment"><fragment></a> component
4740: removed; otherwise, if there is no such attribute or resolving it
4741: fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application
4742: cache selection algorithm</a> with no manifest. The algorithm
4743: must be passed the <code>Document</code> object.</p>
1.1 mike 4744:
4745: <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>
4746:
4747: </dd>
4748:
1.334 mike 4749: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4750: <dd>
4751: <p>Act as described in the "anything else" entry below.</p>
4752: </dd>
4753:
4754: <dt>Any other end tag</dt>
4755: <dd>
4756: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4757: </dd>
4758:
1.1 mike 4759: <dt>Anything else</dt>
4760: <dd>
4761:
1.159 mike 4762: <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.1 mike 4763: <code>Document</code> object. Put this element in the <a href="#stack-of-open-elements">stack
4764: of open elements</a>.</p>
4765:
4766: <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
4767: context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
4768: algorithm</a> with no manifest, passing it the
4769: <code>Document</code> object.</p>
4770:
4771: <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
4772: reprocess the current token.</p>
4773:
4774: </dd>
4775:
4776: </dl><p>The root element can end up being removed from the
4777: <code>Document</code> object, e.g. by scripts; nothing in particular
4778: happens in such cases, content continues being appended to the nodes
4779: as described in the next section.</p>
4780:
4781:
1.614 mike 4782: <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 4783:
4784: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
4785: mode: before head">before head</a>", tokens must be handled as follows:</p>
4786:
4787: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4788: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4789: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4790: <dd>
4791: <p>Ignore the token.</p> <!-- :-( -->
4792: </dd>
4793:
4794: <dt>A comment token</dt>
4795: <dd>
4796: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
4797: node</a> with the <code title="">data</code> attribute set to
4798: the data given in the comment token.</p>
4799: </dd>
4800:
4801: <dt>A DOCTYPE token</dt>
4802: <dd>
4803: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4804: </dd>
4805:
4806: <dt>A start tag whose tag name is "html"</dt>
4807: <dd>
4808: <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
4809: mode</a>.</p>
4810: </dd>
4811:
4812: <dt>A start tag whose tag name is "head"</dt>
4813: <dd>
4814:
4815: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
4816:
4817: <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159 mike 4818: to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 4819:
4820: <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>
4821:
4822: </dd>
4823:
4824: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4825: <dd>
4826:
4827: <p>Act as if a start tag token with the tag name "head" and no
4828: attributes had been seen, then reprocess the current token.</p>
4829:
4830: </dd>
4831:
4832: <dt>Any other end tag</dt>
4833: <dd>
4834:
4835: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4836:
4837: </dd>
4838:
4839: <dt>Anything else</dt>
4840: <dd>
4841:
4842: <p>Act as if a start tag token with the tag name "head" and no
4843: attributes had been seen, then reprocess the current
4844: token.</p>
4845:
4846: </dd>
4847:
1.614 mike 4848: </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 4849:
4850: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
4851: mode: in head">in head</a>", tokens must be handled as follows:</p>
4852:
4853: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4854: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
4855: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
4856: <dd>
4857: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
4858: the <a href="#current-node">current node</a>.</p>
4859: </dd>
4860:
4861: <dt>A comment token</dt>
4862: <dd>
4863: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
4864: node</a> with the <code title="">data</code> attribute set to
4865: the data given in the comment token.</p>
4866: </dd>
4867:
4868: <dt>A DOCTYPE token</dt>
4869: <dd>
4870: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4871: </dd>
4872:
4873: <dt>A start tag whose tag name is "html"</dt>
4874: <dd>
4875: <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
4876: mode</a>.</p>
4877: </dd>
4878:
4879: <dt>A start tag whose tag name is one of: "base", "command",
4880: "link"</dt>
4881: <dd>
4882:
4883: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
4884: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4885: elements</a>.</p>
4886:
4887: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
4888: token's <i>self-closing flag</i></a>, if it is set.</p>
4889:
4890: </dd>
4891:
4892: <dt>A start tag whose tag name is "meta"</dt>
4893: <dd>
4894:
4895: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
4896: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4897: elements</a>.</p>
4898:
4899: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
4900: token's <i>self-closing flag</i></a>, if it is set.</p>
4901:
4902: <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
4903: value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
4904: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
4905: encoding</a> to the encoding given by the value of the
4906: <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
4907:
4908: <p>Otherwise, if the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">content</a></code> attribute, and
4909: applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
4910: Content-Type</a> to its value returns a supported encoding
4911: <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
4912: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
4913: encoding</a> to the encoding <var title="">encoding</var>.</p>
4914:
4915: </dd>
4916:
4917: <dt>A start tag whose tag name is "title"</dt>
4918: <dd>
4919: <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
4920: </dd>
4921:
4922: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
4923: <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
4924: <dd>
1.91 mike 4925: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 4926: </dd>
4927:
4928: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
4929: <dd>
4930:
4931: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
4932:
4933: <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
4934: noscript</a>".</p>
4935:
4936: </dd>
4937:
4938: <dt id="scriptTag">A start tag whose tag name is "script"</dt>
4939: <dd>
4940:
4941: <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
4942: <a href="#html-namespace-0">HTML namespace</a>.</p></li>
4943:
4944: <li>
4945:
4946: <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
4947:
4948: <p class="note">This ensures that, if the script is external,
1.159 mike 4949: any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1 mike 4950: calls in the script will execute in-line, instead of blowing the
4951: document away, as would happen in most other cases. It also
4952: prevents the script from executing until the end tag is
4953: seen.</p>
4954:
4955: </li>
4956:
4957: <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
4958: fragment parsing algorithm</a>, then mark the
1.484 mike 4959: <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
4960: started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1 mike 4961:
4962: <li><p>Append the new element to the <a href="#current-node">current node</a>
4963: and push it onto the <a href="#stack-of-open-elements">stack of open
4964: elements</a>.</p></li>
4965:
1.541 mike 4966: <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
4967: state</a>.</p></li>
1.1 mike 4968:
4969: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
4970: <a href="#insertion-mode">insertion mode</a>.</p>
4971:
1.540 mike 4972: </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 4973:
4974: </ol></dd>
4975:
4976: <dt>An end tag whose tag name is "head"</dt>
4977: <dd>
4978:
4979: <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159 mike 4980: <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 4981: elements</a>.</p>
4982:
4983: <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>
4984:
4985: </dd>
4986:
4987: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
4988: <dd>
4989: <p>Act as described in the "anything else" entry below.</p>
4990: </dd>
4991:
4992: <dt>A start tag whose tag name is "head"</dt>
4993: <dt>Any other end tag</dt>
4994: <dd>
4995: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4996: </dd>
4997:
4998: <dt>Anything else</dt>
4999: <dd>
5000:
5001: <!-- can't get here with an EOF and a fragment case -->
5002:
5003: <p>Act as if an end tag token with the tag name "head" had
5004: been seen, and reprocess the current token.</p>
5005:
5006: </dd>
5007:
1.614 mike 5008: </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 5009:
5010: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
5011: mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
5012:
5013: <dl class="switch"><dt>A DOCTYPE token</dt>
5014: <dd>
5015: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5016: </dd>
5017:
5018: <dt>A start tag whose tag name is "html"</dt>
5019: <dd>
5020: <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
5021: mode</a>.</p>
5022: </dd>
5023:
5024: <dt>An end tag whose tag name is "noscript"</dt>
5025: <dd>
5026:
5027: <p>Pop the <a href="#current-node">current node</a> (which will be a
5028: <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
5029: elements</a>; the new <a href="#current-node">current node</a> will be a
1.159 mike 5030: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 5031:
5032: <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>
5033:
5034: </dd>
5035:
5036: <dt>A character token that is one of U+0009 CHARACTER
5037: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
5038: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
5039: <dt>A comment token</dt>
5040: <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
5041: <dd>
5042: <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
5043: mode</a>.</p>
5044: </dd>
5045:
5046: <dt>An end tag whose tag name is "br"</dt>
5047: <dd>
5048: <p>Act as described in the "anything else" entry below.</p>
5049: </dd>
5050:
5051: <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
5052: <dt>Any other end tag</dt>
5053: <dd>
5054: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5055: </dd>
5056:
5057: <dt>Anything else</dt>
5058: <dd>
5059:
5060: <!-- can't get here with an EOF and a fragment case -->
5061:
5062: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
5063: name "noscript" had been seen and reprocess the current
5064: token.</p>
5065:
5066: </dd>
5067:
1.614 mike 5068: </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 5069:
5070: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
5071: mode: after head">after head</a>", tokens must be handled as follows:</p>
5072:
5073: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
5074: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
5075: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
5076: <dd>
5077: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
5078: the <a href="#current-node">current node</a>.</p>
5079: </dd>
5080:
5081: <dt>A comment token</dt>
5082: <dd>
5083: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
5084: node</a> with the <code title="">data</code> attribute set to
5085: the data given in the comment token.</p>
5086: </dd>
5087:
5088: <dt>A DOCTYPE token</dt>
5089: <dd>
5090: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5091: </dd>
5092:
5093: <dt>A start tag whose tag name is "html"</dt>
5094: <dd>
5095: <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
5096: mode</a>.</p>
5097: </dd>
5098:
5099: <dt>A start tag whose tag name is "body"</dt>
5100: <dd>
5101:
5102: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5103:
5104: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5105:
5106: <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>
5107:
5108: </dd>
5109:
5110: <dt>A start tag whose tag name is "frameset"</dt>
5111: <dd>
5112:
5113: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5114:
5115: <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>
5116:
5117: </dd>
5118:
5119: <dt>A start tag token whose tag name is one of: "base", "link",
5120: "meta", "noframes", "script", "style", "title"</dt>
5121: <dd>
5122:
5123: <p><a href="#parse-error">Parse error</a>.</p>
5124:
5125: <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
5126: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5127:
5128: <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
5129: mode</a>.</p>
5130:
5131: <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
5132: of open elements</a>.</p>
5133:
5134: <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
5135: pointer</a> cannot be null at this point.</p>
5136:
5137: </dd>
5138:
5139: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5140: <dd>
5141: <p>Act as described in the "anything else" entry below.</p>
5142: </dd>
5143:
5144: <dt>A start tag whose tag name is "head"</dt>
5145: <dt>Any other end tag</dt>
5146: <dd>
5147: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5148: </dd>
5149:
5150: <dt>Anything else</dt>
5151: <dd>
5152: <p>Act as if a start tag token with the tag name "body" and no
5153: attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
5154: flag</a> back to "ok", and then reprocess the current
5155: token.</p>
5156: </dd>
5157:
1.614 mike 5158: </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 5159:
5160: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
5161: mode: in body">in body</a>", tokens must be handled as follows:</p>
5162:
5163: <dl class="switch"><dt>A character token</dt>
5164: <dd>
5165:
5166: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5167: any.</p>
5168:
5169: <p><a href="#insert-a-character" title="insert a character">Insert the token's
5170: character</a> into the <a href="#current-node">current node</a>.</p>
5171:
5172: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
5173: LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
5174: (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
5175: flag</a> to "not ok".</p>
5176:
5177: </dd>
5178:
5179: <dt>A comment token</dt>
5180: <dd>
5181: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
5182: node</a> with the <code title="">data</code> attribute set to
5183: the data given in the comment token.</p>
5184: </dd>
5185:
5186: <dt>A DOCTYPE token</dt>
5187: <dd>
5188: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5189: </dd>
5190:
5191: <dt>A start tag whose tag name is "html"</dt>
5192: <dd>
5193: <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
5194: check to see if the attribute is already present on the top
5195: element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
5196: add the attribute and its corresponding value to that element.</p>
5197: </dd>
5198:
5199: <dt>A start tag token whose tag name is one of: "base", "command",
5200: "link", "meta", "noframes", "script", "style", "title"</dt>
5201: <dd>
5202: <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
5203: mode</a>.</p>
5204: </dd>
5205:
5206: <dt>A start tag whose tag name is "body"</dt>
5207: <dd>
5208:
5209: <p><a href="#parse-error">Parse error</a>.</p>
5210:
5211: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5212: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5213: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5214: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5215:
5216: <p>Otherwise, for each attribute on the token, check to see if
1.159 mike 5217: the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 5218: element (the second element) on the <a href="#stack-of-open-elements">stack of open
5219: elements</a>. If it is not, add the attribute and its
5220: corresponding value to that element.</p>
5221:
5222: </dd>
5223:
5224: <dt>A start tag whose tag name is "frameset"</dt>
5225: <dd>
5226:
5227: <p><a href="#parse-error">Parse error</a>.</p>
5228:
5229: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5230: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5231: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5232: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5233:
5234: <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
5235: the token.</p>
5236:
5237: <p>Otherwise, run the following steps:</p>
5238:
5239: <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
5240: elements</a> from its parent node, if it has one.</p></li>
5241:
5242: <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
5243: open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159 mike 5244: but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1 mike 5245:
5246: </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
5247: token.</p></li>
5248:
5249: <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>
5250:
5251: </li></ol></dd>
5252:
5253: <dt>An end-of-file token</dt>
5254: <dd>
5255:
5256: <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422 mike 5257: 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>
5258: 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 5259: <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
5260: <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
5261: <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 5262: <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 5263: this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422 mike 5264: fragment cases) -->
1.1 mike 5265:
5266: <p><a href="#stop-parsing">Stop parsing</a>.</p>
5267:
5268: </dd>
5269:
5270: <dt>An end tag whose tag name is "body"</dt>
5271: <dd>
5272:
5273: <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
5274: in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
5275: token.</p>
5276:
5277: <!-- if we get here, the insertion mode here is forcibly "in
5278: body". -->
5279:
5280: <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422 mike 5281: elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1 mike 5282: <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
5283: <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
5284: <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
5285: <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
5286: <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
5287: <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 5288: <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
5289: <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 5290: error</a>.</p> <!-- (some of those are fragment cases, e.g. for
5291: <tbody> you'd have hit the first paragraph since the <body>
1.422 mike 5292: wouldn't be in scope, unless it was a fragment case) -->
1.1 mike 5293:
5294: <!-- If we ever change the frameset-ok flag to an insertion mode,
5295: then we'd have to somehow keep track of its state when we switch
5296: to after-body. -->
5297:
5298: <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>
5299:
5300: </dd>
5301:
5302: <dt>An end tag whose tag name is "html"</dt>
5303: <dd>
5304:
5305: <p>Act as if an end tag with tag name "body" had been seen,
5306: then, if that token wasn't ignored, reprocess the current
5307: token.</p>
5308:
5309: <p class="note">The fake end tag token here can only be
5310: ignored in the <a href="#fragment-case">fragment case</a>.</p>
5311:
5312: </dd>
5313:
5314: <!-- start tags for non-phrasing flow content elements -->
5315:
5316: <!-- the normal ones -->
5317: <dt>A start tag whose tag name is one of: "address", "article",
1.86 mike 5318: "aside", "blockquote", "center", <!--v2DATAGRID-->"datagrid",
1.305 mike 5319: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5320: "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1 mike 5321: <dd>
5322:
5323: <!-- As of May 2008 this doesn't match any browser exactly, but is
5324: as close to what IE does as I can get without doing the non-tree
5325: DOM nonsense, and thus should actually afford better compatibility
5326: when implemented by the other browsers. -->
5327:
5328: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5329: an element in scope">has a <code>p</code> element in
5330: scope</a>, then act as if an end tag with the tag name
5331: "p" had been seen.</p>
5332:
5333: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5334:
5335: </dd>
5336:
5337: <!-- as normal, but close h1-h6 if it's the current node -->
5338: <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
5339: "h5", "h6"</dt>
5340: <dd>
5341:
5342: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5343: an element in scope">has a <code>p</code> element in
5344: scope</a>, then act as if an end tag with the tag name
5345: "p" had been seen.</p>
5346:
5347: <p>If the <a href="#current-node">current node</a> is an element whose tag name
5348: is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
5349: <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
5350: the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5351: <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
5352:
5353: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5354:
5355: </dd>
5356:
5357: <!-- as normal, but drops leading newline -->
5358: <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
5359: <dd>
5360:
5361: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5362: an element in scope">has a <code>p</code> element in
5363: scope</a>, then act as if an end tag with the tag name
5364: "p" had been seen.</p>
5365:
5366: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5367:
5368: <p>If the next token is a U+000A LINE FEED (LF) character
5369: token, then ignore that token and move on to the next
5370: one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
5371: ignored as an authoring convenience.)</p>
5372:
5373: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5374:
5375: </dd>
5376:
5377: <!-- as normal, but interacts with the form element pointer -->
5378: <dt>A start tag whose tag name is "form"</dt>
5379: <dd>
5380:
5381: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
5382: pointer</a> is not null, then this is a <a href="#parse-error">parse
5383: error</a>; ignore the token.</p>
5384:
5385: <p>Otherwise:</p>
5386:
5387: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5388: an element in scope">has a <code>p</code> element in
5389: scope</a>, then act as if an end tag with the tag name
5390: "p" had been seen.</p>
5391:
5392: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
5393: <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
5394: point to the element created.</p>
5395:
5396: </dd>
5397:
5398: <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
5399: <dt>A start tag whose tag name is "li"</dt>
5400: <dd>
5401:
5402: <p>Run the following algorithm:</p>
5403:
5404: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5405:
5406: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5407: node</a> (the bottommost node of the stack).</p></li>
5408:
1.578 mike 5409: <li><p><i>Loop</i>: If <var title="">node</var> is an
5410: <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
5411: name "li" had been seen, then jump to the last step.</p></li>
1.1 mike 5412:
1.578 mike 5413: <li><p>If <var title="">node</var> is not in the
1.1 mike 5414: <a href="#formatting">formatting</a> category, and is not in the
5415: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5416: <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 5417: element, then jump to the last step.</p></li> <!-- an element
5418: <foo> is in this list if the following markup:
5419:
5420: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
5421:
5422: ...results in the second <li> not being (in any way) a descendant
5423: of the first <li>, or if <foo> is a formatting element that gets
5424: reopened later. -->
5425:
5426: <li><p>Otherwise, set <var title="">node</var> to the previous
5427: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5428: the step labeled <i>loop</i>.</p></li>
5429:
5430: <li>
5431:
5432: <p>This is the last step.</p>
5433:
5434: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5435: an element in scope">has a <code>p</code> element in
5436: scope</a>, then act as if an end tag with the tag name
5437: "p" had been seen.</p>
5438:
5439: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5440: token.</p>
5441:
5442: </li>
5443:
5444: </ol></dd>
5445:
5446: <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases -->
1.422 mike 5447: <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5448: <dd>
5449:
5450: <p>Run the following algorithm:</p>
5451:
5452: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5453:
5454: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5455: node</a> (the bottommost node of the stack).</p></li>
5456:
5457: <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422 mike 5458: <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
5459: tag with the same tag name as <var title="">node</var> had been
5460: seen, then jump to the last step.</p></li>
1.1 mike 5461:
5462: <li><p>If <var title="">node</var> is not in the
5463: <a href="#formatting">formatting</a> category, and is not in the
5464: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5465: <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 5466: element, then jump to the last step.</p></li> <!-- an element
5467: <foo> is in this list if the following markup:
5468:
5469: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
5470:
5471: ...results in the second <dt> not being (in any way) a descendant
5472: of the first <dt>, or if <foo> is a formatting element that gets
5473: reopened later. -->
5474:
5475: <li><p>Otherwise, set <var title="">node</var> to the previous
5476: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5477: the step labeled <i>loop</i>.</p></li>
5478:
5479: <li>
5480:
5481: <p>This is the last step.</p>
5482:
5483: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5484: an element in scope">has a <code>p</code> element in
5485: scope</a>, then act as if an end tag with the tag name
5486: "p" had been seen.</p>
5487:
5488: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5489: token.</p>
5490:
5491: </li>
5492:
5493: </ol></dd>
5494:
5495: <!-- same as normal, but effectively ends parsing -->
5496: <dt>A start tag whose tag name is "plaintext"</dt>
5497: <dd>
5498:
5499: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5500: an element in scope">has a <code>p</code> element in
5501: scope</a>, then act as if an end tag with the tag name
5502: "p" had been seen.</p>
5503:
5504: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5505:
1.541 mike 5506: <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5507:
1.541 mike 5508: <p class="note">Once a start tag with the tag name "plaintext" has
5509: been seen, that will be the last token ever seen other than
5510: character tokens (and the end-of-file token), because there is no
5511: way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5512:
5513: </dd>
5514:
5515: <!-- end tags for non-phrasing flow content elements -->
5516:
5517: <!-- the normal ones -->
5518: <dt>An end tag whose tag name is one of: "address", "article",
1.86 mike 5519: "aside", "blockquote", "center", <!--v2DATAGRID-->"datagrid",
1.305 mike 5520: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5521: "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
5522: "section", "ul"</dt>
1.1 mike 5523: <dd>
5524:
5525: <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>
5526: with the same tag name as that of the token, then this is a
5527: <a href="#parse-error">parse error</a>; ignore the token.</p>
5528:
5529: <p>Otherwise, run these steps:</p>
5530:
5531: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5532:
5533: <li><p>If the <a href="#current-node">current node</a> is not an element with
5534: the same tag name as that of the token, then this is a
5535: <a href="#parse-error">parse error</a>.</p></li>
5536:
5537: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5538: until an element with the same tag name as the token has been
5539: popped from the stack.</p></li>
5540:
5541: </ol></dd>
5542:
5543: <!-- removes the form element pointer instead of the matching node -->
5544: <dt>An end tag whose tag name is "form"</dt>
5545: <dd>
5546:
5547: <p>Let <var title="">node</var> be the element that the
5548: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
5549: to.</p>
5550:
5551: <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
5552: to null.</p>
5553:
5554: <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
5555: elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
5556: scope">have <var title="">node</var> in scope</a>, then this is
5557: a <a href="#parse-error">parse error</a>; ignore the token.</p>
5558:
5559: <p>Otherwise, run these steps:</p>
5560:
5561: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5562:
5563: <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
5564: error</a>.</p></li>
5565:
5566: <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
5567: open elements</a>.</p></li>
5568:
5569: </ol></dd>
5570:
5571: <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
5572: <dt>An end tag whose tag name is "p"</dt>
5573: <dd>
5574:
5575: <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>
5576: with the same tag name as that of the token, then this is a
5577: <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
5578: "p" had been seen, then reprocess the current token.</p>
5579:
5580: <p>Otherwise, run these steps:</p>
5581:
5582: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5583: for elements with the same tag name as the token.</p></li>
5584:
5585: <li><p>If the <a href="#current-node">current node</a> is not an element with
5586: the same tag name as that of the token, then this is a
5587: <a href="#parse-error">parse error</a>.</p></li>
5588:
5589: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5590: until an element with the same tag name as the token has been
5591: popped from the stack.</p></li>
5592:
5593: </ol></dd>
5594:
1.234 mike 5595: <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
5596: <dt>An end tag whose tag name is "li"</dt>
5597: <dd>
5598:
5599: <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
5600: item scope</a> with the same tag name as that of the token,
5601: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5602:
5603: <p>Otherwise, run these steps:</p>
5604:
5605: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5606: for elements with the same tag name as the token.</p></li>
5607:
5608: <li><p>If the <a href="#current-node">current node</a> is not an element with
5609: the same tag name as that of the token, then this is a
5610: <a href="#parse-error">parse error</a>.</p></li>
5611:
5612: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5613: until an element with the same tag name as the token has been
5614: popped from the stack.</p></li>
5615:
5616: </ol></dd>
5617:
1.1 mike 5618: <!-- as normal, but needs care as the elements have optional tags -->
1.422 mike 5619: <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5620: <dd>
5621:
5622: <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>
5623: with the same tag name as that of the token, then this is a
5624: <a href="#parse-error">parse error</a>; ignore the token.</p>
5625:
5626: <p>Otherwise, run these steps:</p>
5627:
5628: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5629: for elements with the same tag name as the token.</p></li>
5630:
5631: <li><p>If the <a href="#current-node">current node</a> is not an element with
5632: the same tag name as that of the token, then this is a
5633: <a href="#parse-error">parse error</a>.</p></li>
5634:
5635: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5636: until an element with the same tag name as the token has been
5637: popped from the stack.</p></li>
5638:
5639: </ol></dd>
5640:
5641: <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
5642: <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
5643: <dd>
5644:
5645: <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>
5646: whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
5647: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5648:
5649: <p>Otherwise, run these steps:</p>
5650:
5651: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5652:
5653: <li><p>If the <a href="#current-node">current node</a> is not an element with
5654: the same tag name as that of the token, then this is a
5655: <a href="#parse-error">parse error</a>.</p></li>
5656:
5657: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5658: until an element whose tag name is one of "h1", "h2", "h3", "h4",
5659: "h5", or "h6" has been popped from the stack.</p></li>
5660:
5661: </ol></dd>
5662:
5663: <dt>An end tag whose tag name is "sarcasm"</dt>
5664: <dd>
5665: <p>Take a deep breath, then act as described in the "any other end
5666: tag" entry below.</p>
5667: </dd>
5668:
5669: <!-- ADOPTION AGENCY ELEMENTS
5670: Mozilla-only: bdo blink del ins sub sup q
5671: Safari-only: code dfn kbd nobr samp var wbr
5672: Both: a b big em font i s small strike strong tt u -->
5673:
5674: <dt>A start tag whose tag name is "a"</dt>
5675: <dd>
5676:
5677: <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
5678: contains an element whose tag name is "a" between the end of
5679: the list and the last marker on the list (or the start of the
5680: list if there is no marker on the list), then this is a
5681: <a href="#parse-error">parse error</a>; act as if an end tag with the tag
5682: name "a" had been seen, then remove that element from the
5683: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
5684: <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
5685: already remove it (it might not have if the element is not
5686: <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
5687: scope</a>).</p>
5688:
5689: <p class="example">In the non-conforming stream
5690: <code><a href="a">a<table><a href="b">b</table>x</code>,
5691: the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing
5692: the second one, and the "x" character would be inside a link
5693: to "b", not to "a". This is despite the fact that the outer
5694: <code><a href="text-level-semantics.html#the-a-element">a</a></code> element is not in table scope (meaning that a
5695: regular <code></a></code> end tag at the start of the table
5696: wouldn't close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element).</p>
5697:
5698: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5699: any.</p>
5700:
5701: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5702: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5703: elements</a>.</p>
5704:
5705: </dd>
5706:
5707: <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
5708: "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
5709: <dd>
5710:
5711: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5712: any.</p>
5713:
5714: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5715: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5716: elements</a>.</p>
5717:
5718: </dd>
5719:
5720: <dt>A start tag whose tag name is "nobr"</dt>
5721: <dd>
5722:
5723: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5724: any.</p>
5725:
5726: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
5727: element in scope">has a <code>nobr</code> element in scope</a>,
5728: then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
5729: the tag name "nobr" had been seen, then once again
5730: <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
5731: any.</p>
5732:
5733: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5734: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5735: elements</a>.</p>
5736:
5737: </dd>
5738:
5739: <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
5740: "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
5741: "strike", "strong", "tt", "u"</dt>
5742: <dd>
5743:
5744: <p>Follow these steps:</p>
5745:
5746: <ol><li>
5747:
5748: <p>Let the <var title="">formatting element</var> be the
5749: last element in the <a href="#list-of-active-formatting-elements">list of active formatting
5750: elements</a> that:</p>
5751:
5752: <ul><li>is between the end of the list and the last scope
5753: marker in the list, if any, or the start of the list
5754: otherwise, and</li>
5755:
5756: <li>has the same tag name as the token.</li>
5757:
5758: </ul><p>If there is no such node, or, if that node is also in the
5759: <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
5760: <a href="#parse-error">parse error</a>; ignore the token, and abort these
5761: steps.</p>
5762:
5763: <p>Otherwise, if there is such a node, but that node is not
5764: in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
5765: <a href="#parse-error">parse error</a>; remove the element from the list,
5766: and abort these steps.</p>
5767:
5768: <p>Otherwise, there is a <var title="">formatting
5769: element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
5770: open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
5771: element in scope">in scope</a>. If the element is not the
5772: <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
5773: error</a>. In any case, proceed with the algorithm as
5774: written in the following steps.</p>
5775:
5776: </li>
5777:
5778: <li><p>Let the <var title="">furthest block</var> be the
5779: topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
5780: is lower in the stack than the <var title="">formatting
5781: element</var>, and is not an element in the
5782: <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
5783: categories. There might not be one.</p></li>
5784:
5785: <li><p>If there is no <var title="">furthest block</var>,
5786: then the UA must skip the subsequent steps and instead just
5787: pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
5788: elements</a>, from the <a href="#current-node">current node</a> up to and
5789: including the <var title="">formatting element</var>, and
5790: remove the <var title="">formatting element</var> from the
5791: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
5792:
5793: <li><p>Let the <var title="">common ancestor</var> be the element
5794: immediately above the <var title="">formatting element</var> in the
5795: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
5796:
5797: <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
5798: formatting elements</a> relative to the elements on either
5799: side of it in the list.</p></li>
5800:
5801: <li>
5802:
5803: <p>Let <var title="">node</var> and <var title="">last node</var> be the
5804: <var title="">furthest block</var>. Follow these steps:</p>
5805:
5806: <ol><li>Let <var title="">node</var> be the element immediately
5807: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436 mike 5808: elements</a>, or if <var title="">node</var> is no longer in
5809: the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
5810: removed by the next step), the element that was immediately
5811: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
5812: elements</a> before <var title="">node</var> was
5813: removed.</li>
1.1 mike 5814:
5815: <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
5816: active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
5817: elements</a> and then go back to step 1.</li>
5818:
5819: <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
5820: in the overall algorithm.</li>
5821:
5822: <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
5823: bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
5824: elements</a>.</li>
5825:
5826: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
5827: element <var title="">node</var> was created, replace the entry
5828: for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
5829: formatting elements</a> with an entry for the new element,
5830: replace the entry for <var title="">node</var> in the
5831: <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
5832: element, and let <var title="">node</var> be the new
5833: element.</li>
5834:
5835: <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
5836: parent node if any.</li>
5837:
5838: <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
5839:
5840: <li>Return to step 1 of this inner set of steps.</li>
5841:
5842: </ol></li>
5843:
5844: <li>
5845:
5846: <p>If the <var title="">common ancestor</var> node is a
5847: <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>,
5848: <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,
5849: <a href="#foster-parent">foster parent</a> whatever <var title="">last
5850: node</var> ended up being in the previous step, first removing
5851: it from its previous parent node if any.</p>
5852:
5853: <p>Otherwise, append whatever <var title="">last node</var>
5854: ended up being in the previous step to the <var title="">common
5855: ancestor</var> node, first removing it from its previous parent
5856: node if any.</p>
5857:
5858: </li>
5859:
5860: <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
5861: <var title="">formatting element</var> was created.</p></li>
5862:
5863: <li><p>Take all of the child nodes of the <var title="">furthest
5864: block</var> and append them to the element created in the last
5865: step.</p></li>
5866:
5867: <li><p>Append that new element to the <var title="">furthest
5868: block</var>.</p></li>
5869:
5870: <li><p>Remove the <var title="">formatting element</var> from the
5871: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
5872: new element into the <a href="#list-of-active-formatting-elements">list of active formatting
5873: elements</a> at the position of the aforementioned
5874: bookmark.</p></li>
5875:
5876: <li><p>Remove the <var title="">formatting element</var> from the
5877: <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
5878: into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
5879: the position of the <var title="">furthest block</var> in that
5880: stack.</p></li>
5881:
5882: <li><p>Jump back to step 1 in this series of steps.</p></li>
5883:
1.334 mike 5884: </ol><p class="note">Because of the way this algorithm causes elements
1.304 mike 5885: to change parents, it has been dubbed the "adoption agency
5886: algorithm" (in contrast with other possible algorithms for dealing
5887: with misnested content, which included the "incest algorithm", the
1.1 mike 5888: "secret affair algorithm", and the "Heisenberg algorithm").</p>
5889:
5890: </dd>
5891:
5892: <dt>A start tag whose tag name is "button"</dt>
5893: <dd>
5894:
5895: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5896: an element in scope">has a <code>button</code> element in
5897: scope</a>, then this is a <a href="#parse-error">parse error</a>;
5898: act as if an end tag with the tag name "button" had been seen,
5899: then reprocess the token.</p>
5900:
5901: <p>Otherwise:</p>
5902:
5903: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5904: any.</p>
5905:
5906: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5907:
5908: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
5909: formatting elements</a>.</p>
5910:
5911: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5912:
5913: </dd>
5914:
5915: <dt>A start tag token whose tag name is one of: "applet",
5916: "marquee", "object"</dt>
5917: <dd>
5918:
5919: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5920: any.</p>
5921:
5922: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5923:
5924: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
5925: formatting elements</a>.</p>
5926:
5927: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5928:
5929: </dd>
5930:
5931: <dt>An end tag token whose tag name is one of: "applet", "button",
5932: "marquee", "object"</dt>
5933: <dd>
5934:
5935: <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>
5936: with the same tag name as that of the token, then this is a
5937: <a href="#parse-error">parse error</a>; ignore the token.</p>
5938:
5939: <p>Otherwise, run these steps:</p>
5940:
5941: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5942:
5943: <li><p>If the <a href="#current-node">current node</a> is not an element with
5944: the same tag name as that of the token, then this is a
5945: <a href="#parse-error">parse error</a>.</p></li>
5946:
5947: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5948: until an element with the same tag name as the token has been
5949: popped from the stack.</p></li>
5950:
5951: <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
5952: last marker</a>.</li>
5953:
5954: </ol></dd>
5955:
5956: <dt>A start tag whose tag name is "table"</dt>
5957: <dd>
5958:
5959: <p>If the <code>Document</code> is <em>not</em> set to
5960: <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
5961: elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
5962: <code>p</code> element in scope</a>, then act as if an end tag
5963: with the tag name "p" had been seen.</p> <!-- i hate myself (this
5964: quirk was basically caused by acid2; if i'd realised we could
5965: change the specs when i wrote acid2, we could have avoided having
5966: any parsing-mode quirks) -Hixie -->
5967:
5968: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5969:
5970: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5971:
5972: <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>
5973:
5974: </dd>
5975:
5976: <dt>A start tag whose tag name is one of: "area", "basefont",
1.589 mike 5977: "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1 mike 5978: <dd>
5979:
5980: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5981: any.</p>
5982:
5983: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5984: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
5985: elements</a>.</p>
5986:
5987: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
5988: token's <i>self-closing flag</i></a>, if it is set.</p>
5989:
5990: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589 mike 5991: shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1 mike 5992:
5993: </dd>
5994:
5995: <dt>A start tag whose tag name is one of: "param", "source"</dt>
5996: <dd>
5997:
5998: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5999: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6000: elements</a>.</p>
6001:
6002: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6003: token's <i>self-closing flag</i></a>, if it is set.</p>
6004:
6005: </dd>
6006:
6007: <dt>A start tag whose tag name is "hr"</dt>
6008: <dd>
6009:
6010: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6011: an element in scope">has a <code>p</code> element in
6012: scope</a>, then act as if an end tag with the tag name
6013: "p" had been seen.</p>
6014:
6015: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6016: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6017: elements</a>.</p>
6018:
6019: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6020: token's <i>self-closing flag</i></a>, if it is set.</p>
6021:
6022: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6023:
6024: </dd>
6025:
6026: <dt>A start tag whose tag name is "image"</dt>
6027: <dd>
6028: <p><a href="#parse-error">Parse error</a>. Change the token's tag name
6029: to "img" and reprocess it. (Don't ask.)</p> <!-- As of
6030: 2005-12, studies showed that around 0.2% of pages used the
6031: <image> element. -->
6032: </dd>
6033:
6034: <dt id="isindex">A start tag whose tag name is "isindex"</dt>
6035: <dd>
6036:
6037: <p><a href="#parse-error">Parse error</a>.</p>
6038:
6039: <p>If the <a href="#form-element-pointer"><code title="">form</code> element
6040: pointer</a> is not null, then ignore the token.</p>
6041:
6042: <p>Otherwise:</p>
6043:
6044: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6045: token's <i>self-closing flag</i></a>, if it is set.</p> <!--
6046: purely to reduce the number of errors (we don't care if they
6047: included the /, they're not supposed to be including the tag at
6048: all! -->
6049:
6050: <p>Act as if a start tag token with the tag name "form" had been seen.</p>
6051:
6052: <p>If the token has an attribute called "action", set the
6053: <code title="attr-form-action">action</code> attribute on the
6054: resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
6055: "action" attribute of the token.</p>
6056:
6057: <p>Act as if a start tag token with the tag name "hr" had been
6058: seen.</p>
6059:
6060: <p>Act as if a start tag token with the tag name "label" had been
6061: seen.</p>
6062:
6063: <p>Act as if a stream of character tokens had been seen (see below
6064: for what they should say).</p>
6065:
6066: <p>Act as if a start tag token with the tag name "input" had been
6067: seen, with all the attributes from the "isindex" token except
6068: "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
6069: <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
6070:
6071: <p>Act as if a stream of character tokens had been seen (see
6072: below for what they should say).</p>
6073:
6074: <p>Act as if an end tag token with the tag name "label" had been
6075: seen.</p>
6076:
6077: <p>Act as if a start tag token with the tag name "hr" had been
6078: seen.</p>
6079:
6080: <p>Act as if an end tag token with the tag name "form" had been
6081: seen.</p>
6082:
6083: <p>If the token has an attribute with the name "prompt", then the
6084: first stream of characters must be the same string as given in
6085: that attribute, and the second stream of characters must be
6086: empty. Otherwise, the two streams of character tokens together
6087: should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
6088: equivalent of "This is a searchable index. Insert your search
6089: keywords here: (input field)" in the user's preferred
6090: language.</p>
6091:
6092: </dd>
6093:
6094: <dt>A start tag whose tag name is "textarea"</dt>
6095: <dd>
6096:
6097: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
6098: token.</p></li>
6099:
6100: <li><p>If the next token is a U+000A LINE FEED (LF) character
6101: token, then ignore that token and move on to the next
6102: one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
6103: ignored as an authoring convenience.)</p></li>
6104:
1.541 mike 6105: <li><p>Switch the tokenizer to the the <a href="#rcdata-state">RCDATA
6106: state</a>.</p></li>
1.1 mike 6107:
6108: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
6109: current <a href="#insertion-mode">insertion mode</a>.</p>
6110:
6111: </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
6112: ok".</p></li>
6113:
1.540 mike 6114: <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 6115:
6116: </ol></dd>
6117:
6118: <dt>A start tag whose tag name is "xmp"</dt>
6119: <dd>
6120:
1.233 mike 6121: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6122: an element in scope">has a <code>p</code> element in
6123: scope</a>, then act as if an end tag with the tag name
6124: "p" had been seen.</p>
6125:
1.1 mike 6126: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6127: any.</p>
6128:
6129: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6130:
1.91 mike 6131: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6132:
6133: </dd>
6134:
6135: <dt>A start tag whose tag name is "iframe"</dt>
6136: <dd>
6137:
6138: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6139:
1.91 mike 6140: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6141:
6142: </dd>
6143:
6144: <dt>A start tag whose tag name is "noembed"</dt>
6145: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
6146: <dd>
6147:
1.91 mike 6148: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6149:
6150: </dd>
6151:
6152: <dt>A start tag whose tag name is "select"</dt>
6153: <dd>
6154:
6155: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6156: any.</p>
6157:
6158: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6159:
6160: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6161:
6162: <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>",
6163: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6164: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
6165: row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
6166: cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
6167: "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
6168: table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
6169: to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
6170:
6171: </dd>
6172:
6173: <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
6174: <dd>
6175:
6176: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6177: element in scope">has an <code>option</code> element in
6178: scope</a>, then act as if an end tag with the tag name "option"
6179: had been seen.</p>
6180:
6181: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6182: any.</p>
6183:
6184: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6185:
6186: </dd>
6187:
6188: <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
6189: <dd>
6190:
6191: <!-- the parsing rules for ruby really don't match IE much at all,
6192: but in practice the markup used is very simple and so strict
6193: compatibility with IE isn't required. For example, as defined
6194: here we get very, very different behaviour than IE for
6195: pathological cases like:
6196:
6197: <ruby><ol><li><p>a<rt>b
6198: <ruby>a<rt>b<p>c
6199:
6200: But in practice most ruby markup falls into these cases:
6201:
6202: <ruby>a<rt>b</ruby>
6203: <ruby>a<rp>b<rt>c<rp>d</ruby>
6204: <ruby>a<rt>b</rt></ruby>
6205: <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
6206:
6207: -->
6208:
6209: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6210: element in scope">has a <code>ruby</code> element in scope</a>,
6211: then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
6212: node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
6213: <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
6214: node</a> up to the node immediately before the bottommost
6215: <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
6216: elements</a>.</p>
6217:
6218: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6219:
6220: </dd>
6221:
6222: <dt>An end tag whose tag name is "br"</dt>
6223: <dd>
6224: <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
6225: the tag name "br" had been seen. Ignore the end tag token.</p>
6226: </dd>
6227:
6228: <dt>A start tag whose tag name is "math"</dt>
6229: <dd>
6230:
6231: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6232: any.</p>
6233:
6234: <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
6235: fixes the case of MathML attributes that are not all
6236: lowercase.)</p>
6237:
6238: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6239: fixes the use of namespaced attributes, in particular XLink.)</p>
6240:
6241: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
6242: <a href="#mathml-namespace">MathML namespace</a>.</p>
6243:
6244: <!-- If we ever change the frameset-ok flag to an insertion mode,
6245: the following change would be implied, except we'd have to do it
6246: even in the face of a self-closed tag:
6247: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6248: -->
6249:
6250: <p>If the token has its <i>self-closing flag</i> set, pop the
6251: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6252: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6253: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6254:
6255: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6256: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6257: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6258: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6259: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6260: foreign content">in foreign content</a>".</p>
6261:
6262: </dd>
6263:
6264: <dt>A start tag whose tag name is "svg"</dt>
6265: <dd>
6266:
6267: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6268: any.</p>
6269:
6270: <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
6271: the case of SVG attributes that are not all lowercase.)</p>
6272:
6273: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6274: fixes the use of namespaced attributes, in particular XLink in
6275: SVG.)</p>
6276:
6277: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
6278: <a href="#svg-namespace">SVG namespace</a>.</p>
6279:
6280: <!-- If we ever change the frameset-ok flag to an insertion mode,
6281: the following change would be implied, except we'd have to do it
6282: even in the face of a self-closed tag:
6283: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6284: -->
6285:
6286: <p>If the token has its <i>self-closing flag</i> set, pop the
6287: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6288: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6289: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6290:
6291: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6292: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6293: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6294: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6295: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6296: foreign content">in foreign content</a>".</p>
6297:
6298: </dd>
6299:
6300: <dt>A start <!--or end--> tag whose tag name is one of: "caption",
6301: "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
6302: "thead", "tr"</dt>
6303: <!--<dt>An end tag whose tag name is one of: "area", "base",
6304: "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
6305: "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589 mike 6306: "noframes", "param", "script", "select", "source", "style",
6307: "table", "textarea", "title", "wbr"</dt>-->
1.1 mike 6308: <!--<dt>An end tag whose tag name is "noscript", if the
6309: <span>scripting flag</span> is enabled</dt>-->
6310: <dd>
6311: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6312: <!-- end tags are commented out because since they can never end
6313: up on the stack anyway, the default end tag clause will
6314: automatically handle them. we don't want to have text in the spec
6315: that is just an optimisation, as that detracts from the spec
6316: itself -->
6317: </dd>
6318:
6319: <dt>Any other start tag</dt>
6320: <dd>
6321:
6322: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6323: any.</p>
6324:
6325: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6326:
6327: <p class="note">This element will be a <a href="#phrasing">phrasing</a>
6328: element.</p>
6329:
6330: </dd>
6331:
6332: <dt>Any other end tag</dt>
6333: <dd>
6334:
6335: <p>Run the following steps:</p>
6336:
6337: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
6338: node</a> (the bottommost node of the stack).</p></li>
6339:
6340: <li><p>If <var title="">node</var> has the same tag name as
6341: the end tag token, then:</p>
6342:
6343: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6344:
6345: <li><p>If the tag name of the end tag token does not match
6346: the tag name of the <a href="#current-node">current node</a>, this is a
6347: <a href="#parse-error">parse error</a>.</p></li>
6348:
6349: <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
6350: to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
6351:
6352: </ol></li>
6353:
6354: <li><p>Otherwise, if <var title="">node</var> is in neither the
6355: <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
6356: category, then this is a <a href="#parse-error">parse error</a>; ignore the
6357: token, and abort these steps.</p></li>
6358:
6359: <li><p>Set <var title="">node</var> to the previous entry in the
6360: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
6361:
6362: <li><p>Return to step 2.</p></li>
6363:
6364: </ol></dd>
6365:
1.614 mike 6366: </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 6367:
6368: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540 mike 6369: mode: text">text</a>", tokens must be handled as follows:</p>
1.1 mike 6370:
6371: <dl class="switch"><dt>A character token</dt>
6372: <dd>
6373:
6374: <p><a href="#insert-a-character" title="insert a character">Insert the token's
6375: character</a> into the <a href="#current-node">current node</a>.</p>
6376:
6377: </dd>
6378:
6379: <dt>An end-of-file token</dt>
6380: <dd>
6381:
6382: <!-- can't be the fragment case -->
6383: <p><a href="#parse-error">Parse error</a>.</p>
6384:
6385: <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484 mike 6386: element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
6387: started"</a>.</p>
1.1 mike 6388:
6389: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6390: elements</a>.</p>
6391:
6392: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6393: insertion mode</a> and reprocess the current token.</p>
6394:
6395: </dd>
6396:
6397: <dt>An end tag whose tag name is "script"</dt>
6398: <dd>
6399:
6400: <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
6401: (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
6402:
6403: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6404: elements</a>.</p>
6405:
6406: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6407: insertion mode</a>.</p>
6408:
6409: <p>Let the <var title="">old insertion point</var> have the
6410: same value as the current <a href="#insertion-point">insertion point</a>. Let
6411: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
6412: input character</a>.</p>
6413:
6414: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
6415: one.</p>
6416:
6417: <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 6418: which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1 mike 6419: to be inserted into the tokenizer</a>, and might cause the
6420: tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
6421:
6422: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
6423: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
6424: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6425:
6426: <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
6427: <a href="#insertion-point">insertion point</a> to its previous value. This value
6428: might be the "undefined" value.)</p>
6429:
6430: <p id="scriptTagParserResumes">At this stage, if there is a
1.484 mike 6431: <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1 mike 6432:
6433: <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
6434:
6435: <dd>
6436:
6437: <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
6438: processing of any nested invocations of the tokenizer, yielding
6439: control back to the caller. (Tokenization will resume when the
6440: caller returns to the "outer" tree construction stage.)</p>
6441:
6442: <p class="note">The tree construction stage of this particular
6443: parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159 mike 6444: 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 6445:
6446: </dd>
6447:
6448:
6449: <dt>Otherwise:</dt>
6450:
6451: <dd>
6452:
6453: <p>Follow these steps:</p>
6454:
1.484 mike 6455: <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
6456: parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
6457: parsing-blocking script</a>.</p></li>
6458:
6459: <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
6460: for this instance of the <a href="#html-parser">HTML parser</a>, such that
6461: 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>
6462:
6463: <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
6464: scripts</a> and <var title="">the script</var>'s
6465: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
6466:
6467: <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
6468: for this instance of the <a href="#html-parser">HTML parser</a>, such that
6469: <a href="browsers.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a> can again be
6470: run.</p></li>
1.1 mike 6471:
6472: <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
6473: <a href="#next-input-character">next input character</a>.</p></li>
6474:
6475: <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
6476: by one (it should be zero before this step, so this sets it to
6477: one).</p></li>
6478:
1.484 mike 6479: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
6480: <var title="">the script</var>.</p></li>
1.1 mike 6481:
6482: <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
6483: by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
6484: zero (which it always should be at this point), then set the
6485: <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6486:
6487: </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
6488: again.</p></li>
6489:
1.484 mike 6490: <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1 mike 6491: script</a>, then repeat these steps from step 1.</p></li>
6492:
6493: </ol></dd>
6494:
6495: </dl></dd>
6496:
6497: <dt>Any other end tag</dt>
6498: <dd>
6499:
6500: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6501: elements</a>.</p>
6502:
6503: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6504: insertion mode</a>.</p>
6505:
6506: </dd>
6507:
1.614 mike 6508: </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 6509:
6510: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
6511: mode: in table">in table</a>", tokens must be handled as follows:</p>
6512:
6513: <dl class="switch"><dt>A character token</dt>
6514: <dd>
6515:
6516: <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
6517: be an empty list of tokens.</p>
6518:
6519: <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
6520: <a href="#insertion-mode">insertion mode</a>.</p>
6521:
6522: <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
6523: reprocess the token.</p>
6524:
6525: </dd>
6526:
6527: <dt>A comment token</dt>
6528: <dd>
6529: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
6530: node</a> with the <code title="">data</code> attribute set to
6531: the data given in the comment token.</p>
6532: </dd>
6533:
6534: <dt>A DOCTYPE token</dt>
6535: <dd>
6536: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6537: </dd>
6538:
6539: <dt>A start tag whose tag name is "caption"</dt>
6540: <dd>
6541:
6542: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6543: below.)</p>
6544:
6545: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6546: formatting elements</a>.</p>
6547:
6548: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6549: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
6550:
6551: </dd>
6552:
6553: <dt>A start tag whose tag name is "colgroup"</dt>
6554: <dd>
6555:
6556: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6557: below.)</p>
6558:
6559: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6560: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
6561: group</a>".</p>
6562:
6563: </dd>
6564:
6565: <dt>A start tag whose tag name is "col"</dt>
6566: <dd>
6567: <p>Act as if a start tag token with the tag name "colgroup"
6568: had been seen, then reprocess the current token.</p>
6569: </dd>
6570:
6571: <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
6572: <dd>
6573:
6574: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6575: below.)</p>
6576:
6577: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6578: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6579: body</a>".</p>
6580:
6581: </dd>
6582:
6583: <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
6584: <dd>
6585: <p>Act as if a start tag token with the tag name "tbody" had
6586: been seen, then reprocess the current token.</p>
6587: </dd>
6588:
6589: <dt>A start tag whose tag name is "table"</dt>
6590: <dd>
6591:
6592: <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
6593: the tag name "table" had been seen, then, if that token wasn't
6594: ignored, reprocess the current token.</p>
6595:
6596: <p class="note">The fake end tag token here can only be
6597: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6598:
6599: </dd>
6600:
6601: <dt>An end tag whose tag name is "table"</dt>
6602: <dd>
6603:
6604: <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
6605: scope</a> with the same tag name as the token, this is a
6606: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6607: case</a>)</p>
6608:
6609: <p>Otherwise:</p>
6610:
6611: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
6612: element has been popped from the stack.</p>
6613:
6614: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
6615:
6616: </dd>
6617:
6618: <dt>An end tag whose tag name is one of: "body", "caption",
6619: "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
6620: "thead", "tr"</dt>
6621: <dd>
6622: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6623: </dd>
6624:
6625: <dt>A start tag whose tag name is one of: "style", "script"</dt>
6626: <dd>
6627:
6628: <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
6629: mode</a>.</p>
6630:
6631: </dd>
6632:
6633: <dt>A start tag whose tag name is "input"</dt>
6634: <dd>
6635:
6636: <p>If the token does not have an attribute with the name "type",
6637: or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
6638: case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
6639: else" entry below.</p>
6640:
6641: <p>Otherwise:</p>
6642:
6643: <p><a href="#parse-error">Parse error</a>.</p>
6644:
6645: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6646:
6647: <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
6648: open elements</a>.</p>
6649:
6650: </dd>
6651:
1.603 mike 6652: <dt>A start tag whose tag name is "form"</dt>
6653: <dd>
6654:
6655: <p><a href="#parse-error">Parse error</a>.</p>
6656:
6657: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6658:
1.637 mike 6659: <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 6660: open elements</a>.</p>
6661:
6662: </dd>
6663:
1.1 mike 6664: <dt>An end-of-file token</dt>
6665: <dd>
6666:
6667: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 6668: <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 6669: error</a>.</p>
6670:
6671: <p class="note">It can only be the <a href="#current-node">current node</a> in
6672: the <a href="#fragment-case">fragment case</a>.</p>
6673:
6674: <p><a href="#stop-parsing">Stop parsing</a>.</p>
6675:
6676: </dd>
6677:
6678: <dt>Anything else</dt>
6679: <dd>
6680:
6681: <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
6682: rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
6683: body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
6684: <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
6685: <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
6686: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
6687: into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
6688:
6689: </dd>
6690:
6691: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
6692: back to a table context</dfn>, it means that the UA must, while
6693: 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 6694: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 6695: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
6696:
6697: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 6698: <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 6699: case</a>.</p>
6700:
6701:
6702:
1.614 mike 6703: <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 6704:
6705: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
6706: mode: in table text">in table text</a>", tokens must be handled
6707: as follows:</p>
6708:
6709: <dl class="switch"><dt>A character token</dt>
6710: <dd>
6711:
6712: <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
6713: tokens</a></var> list.</p>
6714:
6715: </dd>
6716:
6717:
6718: <dt>Anything else</dt>
6719: <dd>
6720:
6721: <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
6722: tokens</a></var> list are character tokens that are not one of U+0009
6723: CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
6724: (FF), <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE, then
6725: reprocess those character tokens using the rules given in the
6726: "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
6727: table">in table</a>" insertion mode.</p>
6728:
6729: <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
6730: characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
6731: tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
6732:
6733: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6734: insertion mode</a> and reprocess the token.</p>
6735:
6736: </dd>
6737:
1.614 mike 6738: </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 6739:
6740: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
6741: mode: in caption">in caption</a>", tokens must be handled as follows:</p>
6742:
6743: <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
6744: <dd>
6745:
6746: <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
6747: scope</a> with the same tag name as the token, this is a
6748: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6749: case</a>)</p>
6750:
6751: <p>Otherwise:</p>
6752:
6753: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
6754:
6755: <p>Now, if the <a href="#current-node">current node</a> is not a
6756: <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
6757: error</a>.</p>
6758:
6759: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
6760: element has been popped from the stack.</p>
6761:
6762: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
6763: the last marker</a>.</p>
6764:
6765: <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>
6766:
6767: </dd>
6768:
6769: <dt>A start tag whose tag name is one of: "caption", "col",
6770: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
6771: <dt>An end tag whose tag name is "table"</dt>
6772: <dd>
6773:
6774: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
6775: name "caption" had been seen, then, if that token wasn't
6776: ignored, reprocess the current token.</p>
6777:
6778: <p class="note">The fake end tag token here can only be
6779: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6780:
6781: </dd>
6782:
6783: <dt>An end tag whose tag name is one of: "body", "col",
6784: "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
6785: "tr"</dt>
6786: <dd>
6787: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6788: </dd>
6789:
6790: <dt>Anything else</dt>
6791: <dd>
6792: <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
6793: mode</a>.</p>
6794: </dd>
6795:
1.614 mike 6796: </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 6797:
6798: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
6799: mode: in column group">in column group</a>", tokens must be handled as follows:</p>
6800:
6801: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
6802: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
6803: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
6804: <dd>
6805: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
6806: the <a href="#current-node">current node</a>.</p>
6807: </dd>
6808:
6809: <dt>A comment token</dt>
6810: <dd>
6811: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
6812: node</a> with the <code title="">data</code> attribute set to
6813: the data given in the comment token.</p>
6814: </dd>
6815:
6816: <dt>A DOCTYPE token</dt>
6817: <dd>
6818: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6819: </dd>
6820:
6821: <dt>A start tag whose tag name is "html"</dt>
6822: <dd>
6823: <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
6824: mode</a>.</p>
6825: </dd>
6826:
6827: <dt>A start tag whose tag name is "col"</dt>
6828: <dd>
6829:
6830: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6831: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6832: elements</a>.</p>
6833:
6834: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6835: token's <i>self-closing flag</i></a>, if it is set.</p>
6836:
6837: </dd>
6838:
6839: <dt>An end tag whose tag name is "colgroup"</dt>
6840: <dd>
6841:
6842: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 6843: <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 6844: error</a>; ignore the token. (<a href="#fragment-case">fragment
6845: case</a>)</p>
6846:
6847: <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
6848: 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
6849: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
6850: "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
6851:
6852: </dd>
6853:
6854: <dt>An end tag whose tag name is "col"</dt>
6855: <dd>
6856: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6857: </dd>
6858:
6859: <dt>An end-of-file token</dt>
6860: <dd>
6861:
1.159 mike 6862: <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 6863: element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
6864: case</a>)</p>
6865:
6866: <p>Otherwise, act as described in the "anything else" entry
6867: below.</p>
6868:
6869: </dd>
6870:
6871: <dt>Anything else</dt>
6872: <dd>
6873:
6874: <p>Act as if an end tag with the tag name "colgroup" had been
6875: seen, and then, if that token wasn't ignored, reprocess the
6876: current token.</p>
6877:
6878: <p class="note">The fake end tag token here can only be
6879: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6880:
6881: </dd>
6882:
1.614 mike 6883: </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 6884:
6885: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
6886: mode: in table body">in table body</a>", tokens must be handled as follows:</p>
6887:
6888: <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
6889: <dd>
6890:
6891: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
6892: context</a>. (See below.)</p>
6893:
6894: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
6895: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
6896: in row">in row</a>".</p>
6897:
6898: </dd>
6899:
6900: <dt>A start tag whose tag name is one of: "th", "td"</dt>
6901: <dd>
6902: <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
6903: the tag name "tr" had been seen, then reprocess the current
6904: token.</p>
6905: </dd>
6906:
6907: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
6908: "thead"</dt>
6909: <dd>
6910:
6911: <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
6912: scope</a> with the same tag name as the token, this is a
6913: <a href="#parse-error">parse error</a>. Ignore the token.</p>
6914:
6915: <p>Otherwise:</p>
6916:
6917: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
6918: context</a>. (See below.)</p>
6919:
6920: <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
6921: open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
6922: to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
6923:
6924: </dd>
6925:
6926: <dt>A start tag whose tag name is one of: "caption", "col",
6927: "colgroup", "tbody", "tfoot", "thead"</dt>
6928: <dt>An end tag whose tag name is "table"</dt>
6929: <dd>
6930:
6931: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
6932: <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
6933: element in table scope</a>, this is a <a href="#parse-error">parse
6934: error</a>. Ignore the token. (<a href="#fragment-case">fragment
6935: case</a>)</p>
6936:
6937: <p>Otherwise:</p>
6938:
6939: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
6940: context</a>. (See below.)</p>
6941:
6942: <p>Act as if an end tag with the same tag name as the
6943: <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
6944: been seen, then reprocess the current token.</p>
6945:
6946: </dd>
6947:
6948: <dt>An end tag whose tag name is one of: "body", "caption",
6949: "col", "colgroup", "html", "td", "th", "tr"</dt>
6950: <dd>
6951: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6952: </dd>
6953:
6954: <dt>Anything else</dt>
6955: <dd>
6956: <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
6957: mode</a>.</p>
6958: </dd>
6959:
6960: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
6961: back to a table body context</dfn>, it means that the UA must,
6962: 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 6963: <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 6964: element, pop elements from the <a href="#stack-of-open-elements">stack of open
6965: elements</a>.</p>
6966:
6967: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 6968: <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 6969: case</a>.</p>
6970:
6971:
1.614 mike 6972: <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 6973:
6974: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
6975: mode: in row">in row</a>", tokens must be handled as follows:</p>
6976:
6977: <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
6978: <dd>
6979:
6980: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
6981: context</a>. (See below.)</p>
6982:
6983: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
6984: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
6985: in cell">in cell</a>".</p>
6986:
6987: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6988: formatting elements</a>.</p>
6989:
6990: </dd>
6991:
6992: <dt>An end tag whose tag name is "tr"</dt>
6993: <dd>
6994:
6995: <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
6996: scope</a> with the same tag name as the token, this is a
6997: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6998: case</a>)</p>
6999:
7000: <p>Otherwise:</p>
7001:
7002: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7003: context</a>. (See below.)</p>
7004:
7005: <p>Pop the <a href="#current-node">current node</a> (which will be a
7006: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
7007: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
7008: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
7009: body</a>".</p>
7010:
7011: </dd>
7012:
7013: <dt>A start tag whose tag name is one of: "caption", "col",
7014: "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
7015: <dt>An end tag whose tag name is "table"</dt>
7016: <dd>
7017:
7018: <p>Act as if an end tag with the tag name "tr" had been seen,
7019: then, if that token wasn't ignored, reprocess the current
7020: token.</p>
7021:
7022: <p class="note">The fake end tag token here can only be
7023: ignored in the <a href="#fragment-case">fragment case</a>.</p>
7024:
7025: </dd>
7026:
7027: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
7028: "thead"</dt>
7029: <dd>
7030:
7031: <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
7032: scope</a> with the same tag name as the token, this is a
7033: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7034:
7035: <p>Otherwise, act as if an end tag with the tag name "tr" had
7036: been seen, then reprocess the current token.</p>
7037:
7038: </dd>
7039:
7040: <dt>An end tag whose tag name is one of: "body", "caption",
7041: "col", "colgroup", "html", "td", "th"</dt>
7042: <dd>
7043: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7044: </dd>
7045:
7046: <dt>Anything else</dt>
7047: <dd>
7048: <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
7049: mode</a>.</p>
7050: </dd>
7051:
7052: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
7053: back to a table row context</dfn>, it means that the UA must,
7054: 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 7055: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 7056: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7057:
7058: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 7059: <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 7060: case</a>.</p>
7061:
7062:
1.614 mike 7063: <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 7064:
7065: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
7066: mode: in cell">in cell</a>", tokens must be handled as follows:</p>
7067:
7068: <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
7069: <dd>
7070:
7071: <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
7072: scope</a> with the same tag name as that of the token, then
7073: this is a <a href="#parse-error">parse error</a> and the token must be
7074: ignored.</p>
7075:
7076: <p>Otherwise:</p>
7077:
7078: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
7079:
7080: <p>Now, if the <a href="#current-node">current node</a> is not an element
7081: with the same tag name as the token, then this is a
7082: <a href="#parse-error">parse error</a>.</p>
7083:
7084: <p>Pop elements from this stack until an element with the same
7085: tag name as the token has been popped from the stack.</p>
7086:
7087: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
7088: the last marker</a>.</p>
7089:
7090: <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
7091: <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
7092: this point.)</p>
7093:
7094: </dd>
7095:
7096: <dt>A start tag whose tag name is one of: "caption", "col",
7097: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
7098: <dd>
7099:
7100: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
7101: <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
7102: a <code>td</code> or <code>th</code> element in table
7103: scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
7104: the token. (<a href="#fragment-case">fragment case</a>)</p>
7105:
7106: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7107: reprocess the current token.</p>
7108:
7109: </dd>
7110:
7111: <dt>An end tag whose tag name is one of: "body", "caption",
7112: "col", "colgroup", "html"</dt>
7113: <dd>
7114: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7115: </dd>
7116:
7117: <dt>An end tag whose tag name is one of: "table", "tbody",
7118: "tfoot", "thead", "tr"</dt>
7119: <dd>
7120:
7121: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
7122: scope</a> with the same tag name as that of the token
7123: (which can only happen for "tbody", "tfoot" and "thead", or,
7124: in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
7125: error</a> and the token must be ignored.</p>
7126:
7127: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7128: reprocess the current token.</p>
7129:
7130: </dd>
7131:
7132: <dt>Anything else</dt>
7133: <dd>
7134: <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
7135: mode</a>.</p>
7136: </dd>
7137:
7138: </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
7139: mean to run the following algorithm:</p>
7140:
7141: <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>
7142: element in table scope</a>, then act as if an end tag token
7143: with the tag name "td" had been seen.</p></li>
7144:
7145: <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
7146: <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
7147: <code>th</code> element in table scope</a>; act as if an end
7148: tag token with the tag name "th" had been seen.</p></li>
7149:
7150: </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
7151: 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
7152: the same time, nor can it have neither when the <a href="#insertion-mode">insertion
7153: mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
7154: cell</a>".</p>
7155:
7156:
1.614 mike 7157: <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 7158:
7159: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
7160: mode: in select">in select</a>", tokens must be handled as follows:</p>
7161:
7162: <dl class="switch"><dt>A character token</dt>
7163: <dd>
7164: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7165: character</a> into the <a href="#current-node">current node</a>.</p>
7166: </dd>
7167:
7168: <dt>A comment token</dt>
7169: <dd>
7170: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7171: node</a> with the <code title="">data</code> attribute set to
7172: the data given in the comment token.</p>
7173: </dd>
7174:
7175: <dt>A DOCTYPE token</dt>
7176: <dd>
7177: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7178: </dd>
7179:
7180: <dt>A start tag whose tag name is "html"</dt>
7181: <dd>
7182: <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
7183: mode</a>.</p>
7184: </dd>
7185:
7186: <dt>A start tag whose tag name is "option"</dt>
7187: <dd>
7188:
7189: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7190: element, act as if an end tag with the tag name "option" had
7191: been seen.</p>
7192:
7193: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7194:
7195: </dd>
7196:
7197: <dt>A start tag whose tag name is "optgroup"</dt>
7198: <dd>
7199:
7200: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7201: element, act as if an end tag with the tag name "option" had
7202: been seen.</p>
7203:
7204: <p>If the <a href="#current-node">current node</a> is an
7205: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
7206: tag name "optgroup" had been seen.</p>
7207:
7208: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7209:
7210: </dd>
7211:
7212: <dt>An end tag whose tag name is "optgroup"</dt>
7213: <dd>
7214:
7215: <p>First, if the <a href="#current-node">current node</a> is an
7216: <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
7217: it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
7218: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
7219: the tag name "option" had been seen.</p>
7220:
7221: <p>If the <a href="#current-node">current node</a> is an
7222: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
7223: <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
7224: <a href="#parse-error">parse error</a>; ignore the token.</p>
7225:
7226: </dd>
7227:
7228: <dt>An end tag whose tag name is "option"</dt>
7229: <dd>
7230:
7231: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7232: element, then pop that node from the <a href="#stack-of-open-elements">stack of open
7233: elements</a>. Otherwise, this is a <a href="#parse-error">parse
7234: error</a>; ignore the token.</p>
7235:
7236: </dd>
7237:
7238: <dt>An end tag whose tag name is "select"</dt>
7239: <dd>
7240:
7241: <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
7242: scope</a> with the same tag name as the token, this is a
7243: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7244: case</a>)</p>
7245:
7246: <p>Otherwise:</p>
7247:
7248: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
7249: until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
7250: stack.</p>
7251:
7252: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
7253:
7254: </dd>
7255:
7256: <dt>A start tag whose tag name is "select"</dt>
7257: <dd>
7258:
7259: <p><a href="#parse-error">Parse error</a>. Act as if the token had been
7260: an end tag with the tag name "select" instead.</p>
7261:
7262: </dd>
7263:
7264: <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
7265: <dd>
1.73 mike 7266:
7267: <p><a href="#parse-error">Parse error</a>.</p>
7268:
1.124 mike 7269: <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>
7270: element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
7271: case</a>)</p>
1.73 mike 7272:
7273: <p>Otherwise, act as if an end tag with the tag name "select" had
7274: been seen, and reprocess the token.</p>
7275:
1.1 mike 7276: </dd>
7277:
7278: <dt>A start tag token whose tag name is "script"</dt>
7279: <dd>
7280: <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
7281: mode</a>.</p>
7282: </dd>
7283:
7284: <dt>An end-of-file token</dt>
7285: <dd>
7286:
7287: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7288: <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 7289: error</a>.</p>
7290:
7291: <p class="note">It can only be the <a href="#current-node">current node</a> in
7292: the <a href="#fragment-case">fragment case</a>.</p>
7293:
7294: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7295:
7296: </dd>
7297:
7298: <dt>Anything else</dt>
7299: <dd>
7300: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7301: </dd>
7302:
1.614 mike 7303: </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 7304:
7305: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
7306: mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
7307:
7308: <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
7309: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7310: <dd>
7311: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
7312: name "select" had been seen, and reprocess the token.</p>
7313: </dd>
7314:
7315: <dt>An end tag whose tag name is one of: "caption", "table",
7316: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7317: <dd>
7318:
7319: <p><a href="#parse-error">Parse error</a>.</p>
7320:
7321: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
7322: element in table scope</a> with the same tag name as that
7323: of the token, then act as if an end tag with the tag name
7324: "select" had been seen, and reprocess the token. Otherwise,
7325: ignore the token.</p>
7326:
7327: </dd>
7328:
7329: <dt>Anything else</dt>
7330: <dd>
7331: <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
7332: mode</a>.</p>
7333: </dd>
7334:
1.614 mike 7335: </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 7336:
7337: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
7338: mode: in foreign content">in foreign content</a>", tokens must be
7339: handled as follows:</p>
7340:
7341: <dl class="switch"><dt>A character token</dt>
7342: <dd>
7343:
7344: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7345: character</a> into the <a href="#current-node">current node</a>.</p>
7346:
7347: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
7348: LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
7349: (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
7350: flag</a> to "not ok".</p>
7351:
7352: </dd>
7353:
7354: <dt>A comment token</dt>
7355: <dd>
7356: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7357: node</a> with the <code title="">data</code> attribute set to
7358: the data given in the comment token.</p>
7359: </dd>
7360:
7361: <dt>A DOCTYPE token</dt>
7362: <dd>
7363: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7364: </dd>
7365:
7366: <dt>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>
7367: <dd>
7368:
7369: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7370: elements</a>.</p>
7371:
7372: <p>Let the <var title="">old insertion point</var> have the
7373: same value as the current <a href="#insertion-point">insertion point</a>. Let
7374: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
7375: input character</a>.</p>
7376:
7377: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
7378: one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
7379:
7380: <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
7381: the <code title="">script</code> element</a> according to the SVG
1.187 mike 7382: rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1 mike 7383:
1.159 mike 7384: <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 7385: tokenizer</a>, the parser will not be executed reentrantly,
7386: since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
7387:
7388: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
7389: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
7390: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
7391:
7392: <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
7393: <a href="#insertion-point">insertion point</a> to its previous value. This value
7394: might be the "undefined" value.)</p>
7395:
7396: </dd>
7397:
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="">mi</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="">mo</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="">mn</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="">ms</code> element in the <a href="#mathml-namespace">MathML namespace</a>.</dt>
7402: <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>
7403: <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>
7404: <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>
7405: <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>
7406: <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>
7407: <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>
7408: <dt>An end tag</dt>
7409: <dd>
7410:
7411: <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
7412: <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7413:
7414: <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
7415: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336 mike 7416: content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
7417: element in scope">in scope</a> that has a namespace other than
7418: the <a href="#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1 mike 7419: mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7420:
7421: </dd>
7422:
7423: <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
7424: "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422 mike 7425: "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
7426: uniformly throughout the parser -->, "em", "embed", "h1", "h2",
7427: "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1 mike 7428: completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
7429: "li", "listing"<!-- so that pre and listing can be handled
7430: uniformly throughout the parser -->, "menu", "meta", "nobr",
7431: "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
7432: the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
7433: "span", "strong", "strike"<!-- so that s and strike can be handled
7434: uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305 mike 7435: "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
7436: list was determined empirically by studying over 6,000,000,000
1.422 mike 7437: pages that were specifically not XML pages -->
7438: <dt>A start tag whose tag name is "font", if the token has any
7439: attributes named "color", "face", or "size"</dt> <!-- the
7440: attributes here are required so that SVG <font> will go through as
7441: SVG but legacy <font>s won't -->
7442: <dt>An end-of-file token</dt> <dd>
1.1 mike 7443:
7444: <p><a href="#parse-error">Parse error</a>.</p>
7445:
7446: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
7447: the <a href="#current-node">current node</a> is in the <a href="#html-namespace-0">HTML
7448: namespace</a>.</p>
7449:
7450: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#secondary-insertion-mode">secondary
7451: insertion mode</a>, and reprocess the token.</p>
7452:
7453: </dd>
7454:
7455: <dt>Any other start tag</dt>
7456: <dd>
7457:
7458: <p>If the <a href="#current-node">current node</a> is an element in the
7459: <a href="#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
7460: attributes</a> for the token. (This fixes the case of MathML
7461: attributes that are not all lowercase.)</p>
7462:
7463: <p>If the <a href="#current-node">current node</a> is an element in the <a href="#svg-namespace">SVG
7464: namespace</a>, and the token's tag name is one of the ones in
7465: the first column of the following table, change the tag name to
7466: the name given in the corresponding cell in the second
7467: column. (This fixes the case of SVG elements that are not all
7468: lowercase.)</p>
7469:
7470: <table><thead><tr><th> Tag name </th><th> Element name
7471: </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
7472: </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
7473: </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
7474: </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
7475: </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
7476: </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
7477: </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
7478: </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
7479: </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
7480: </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
7481: </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
7482: </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
7483: </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
7484: </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
7485: </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
7486: </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
7487: </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
7488: </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
7489: </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
7490: </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
7491: </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
7492: </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
7493: </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
7494: </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
7495: </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
7496: </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
7497: </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
7498: </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
7499: </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
7500: </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
7501: </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
7502: </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
7503: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
7504: </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
7505: </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
7506: <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
7507: </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
7508: </td></tr></tbody></table><p>If the <a href="#current-node">current node</a> is an element in the <a href="#svg-namespace">SVG
7509: namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
7510: token. (This fixes the case of SVG attributes that are not all
7511: lowercase.)</p>
7512:
7513: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
7514: fixes the use of namespaced attributes, in particular XLink in
7515: SVG.)</p>
7516:
7517: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
7518: same namespace as the <a href="#current-node">current node</a>.</p>
7519:
7520: <p>If the token has its <i>self-closing flag</i> set, pop the
7521: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7522: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
7523: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
7524:
7525: </dd>
7526:
1.614 mike 7527: </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 7528:
7529: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
7530: mode: after body">after body</a>", tokens must be handled as follows:</p>
7531:
7532: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7533: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7534: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7535: <dd>
7536: <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
7537: mode</a>.</p>
7538: </dd>
7539:
7540: <dt>A comment token</dt>
7541: <dd>
7542: <p>Append a <code>Comment</code> node to the first element in
1.159 mike 7543: 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 7544: element), with the <code title="">data</code> attribute set to
7545: the data given in the comment token.</p>
7546: </dd>
7547:
7548: <dt>A DOCTYPE token</dt>
7549: <dd>
7550: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7551: </dd>
7552:
7553: <dt>A start tag whose tag name is "html"</dt>
7554: <dd>
7555: <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
7556: mode</a>.</p>
7557: </dd>
7558:
7559: <dt>An end tag whose tag name is "html"</dt>
7560: <dd>
7561:
7562: <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
7563: fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
7564: error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
7565:
7566: <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
7567: body</a>".</p>
7568:
7569: </dd>
7570:
7571: <dt>An end-of-file token</dt>
7572: <dd>
7573: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7574: </dd>
7575:
7576: <dt>Anything else</dt>
7577: <dd>
7578:
7579: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
7580: mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
7581: body</a>" and reprocess the token.</p>
7582:
7583: </dd>
7584:
1.614 mike 7585: </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 7586:
7587: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
7588: mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
7589:
7590: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7591: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7592: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7593: <dd>
7594: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7595: the <a href="#current-node">current node</a>.</p>
7596: </dd>
7597:
7598: <dt>A comment token</dt>
7599: <dd>
7600: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7601: node</a> with the <code title="">data</code> attribute set to
7602: the data given in the comment token.</p>
7603: </dd>
7604:
7605: <dt>A DOCTYPE token</dt>
7606: <dd>
7607: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7608: </dd>
7609:
7610: <dt>A start tag whose tag name is "html"</dt>
7611: <dd>
7612: <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
7613: mode</a>.</p>
7614: </dd>
7615:
7616: <dt>A start tag whose tag name is "frameset"</dt>
7617: <dd>
7618: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7619: </dd>
7620:
7621: <dt>An end tag whose tag name is "frameset"</dt>
7622: <dd>
7623:
7624: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 7625: <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 7626: error</a>; ignore the token. (<a href="#fragment-case">fragment
7627: case</a>)</p>
7628:
7629: <p>Otherwise, pop the <a href="#current-node">current node</a> from the
7630: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7631:
7632: <p>If the parser was <em>not</em> originally created as part
7633: of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
7634: (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5 mike 7635: node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1 mike 7636: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
7637: frameset</a>".</p>
7638:
7639: </dd>
7640:
7641: <dt>A start tag whose tag name is "frame"</dt>
7642: <dd>
7643:
7644: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
7645: Immediately pop the <a href="#current-node">current node</a> off the
7646: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7647:
7648: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
7649: token's <i>self-closing flag</i></a>, if it is set.</p>
7650:
7651: </dd>
7652:
7653: <dt>A start tag whose tag name is "noframes"</dt>
7654: <dd>
7655: <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
7656: mode</a>.</p>
7657: </dd>
7658:
7659: <dt>An end-of-file token</dt>
7660: <dd>
7661:
7662: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7663: <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 7664: error</a>.</p>
7665:
7666: <p class="note">It can only be the <a href="#current-node">current node</a> in
7667: the <a href="#fragment-case">fragment case</a>.</p>
7668:
7669: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7670:
7671: </dd>
7672:
7673: <dt>Anything else</dt>
7674: <dd>
7675: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7676: </dd>
7677:
1.614 mike 7678: </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 7679:
7680: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
7681: mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
7682:
7683: <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
7684: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7685: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7686: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7687: <dd>
7688: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7689: the <a href="#current-node">current node</a>.</p>
7690: </dd>
7691:
7692: <dt>A comment token</dt>
7693: <dd>
7694: <p>Append a <code>Comment</code> node to the <a href="#current-node">current
7695: node</a> with the <code title="">data</code> attribute set to
7696: the data given in the comment token.</p>
7697: </dd>
7698:
7699: <dt>A DOCTYPE token</dt>
7700: <dd>
7701: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7702: </dd>
7703:
7704: <dt>A start tag whose tag name is "html"</dt>
7705: <dd>
7706: <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
7707: mode</a>.</p>
7708: </dd>
7709:
7710: <dt>An end tag whose tag name is "html"</dt>
7711: <dd>
7712: <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
7713: frameset</a>".</p>
7714: </dd>
7715:
7716: <dt>A start tag whose tag name is "noframes"</dt>
7717: <dd>
7718: <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
7719: mode</a>.</p>
7720: </dd>
7721:
7722: <dt>An end-of-file token</dt>
7723: <dd>
7724: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7725: </dd>
7726:
7727: <dt>Anything else</dt>
7728: <dd>
7729: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7730: </dd>
7731:
1.614 mike 7732: </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 7733:
7734: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
7735: mode: after after body">after after body</a>", tokens must be handled as follows:</p>
7736:
7737: <dl class="switch"><dt>A comment token</dt>
7738: <dd>
7739: <p>Append a <code>Comment</code> node to the <code>Document</code>
7740: object with the <code title="">data</code> attribute set to the
7741: data given in the comment token.</p>
7742: </dd>
7743:
7744: <dt>A DOCTYPE token</dt>
7745: <dt>A character token that is one of U+0009 CHARACTER
7746: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7747: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7748: <dt>A start tag whose tag name is "html"</dt>
7749: <dd>
7750: <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
7751: mode</a>.</p>
7752: </dd>
7753:
7754: <dt>An end-of-file token</dt>
7755: <dd>
7756: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7757: </dd>
7758:
7759: <dt>Anything else</dt>
7760: <dd>
7761: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7762: to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
7763: reprocess the token.</p>
7764: </dd>
7765:
1.614 mike 7766: </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 7767:
7768: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
7769: mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
7770:
7771: <dl class="switch"><dt>A comment token</dt>
7772: <dd>
7773: <p>Append a <code>Comment</code> node to the <code>Document</code>
7774: object with the <code title="">data</code> attribute set to the
7775: data given in the comment token.</p>
7776: </dd>
7777:
7778: <dt>A DOCTYPE token</dt>
7779: <dt>A character token that is one of U+0009 CHARACTER
7780: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
7781: <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
7782: <dt>A start tag whose tag name is "html"</dt>
7783: <dd>
7784: <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
7785: mode</a>.</p>
7786: </dd>
7787:
7788: <dt>An end-of-file token</dt>
7789: <dd>
7790: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7791: </dd>
7792:
7793: <dt>A start tag whose tag name is "noframes"</dt>
7794: <dd>
7795: <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
7796: mode</a>.</p>
7797: </dd>
7798:
7799: <dt>Anything else</dt>
7800: <dd>
7801: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7802: </dd>
7803:
1.266 mike 7804: </dl></div><div class="impl">
7805:
1.614 mike 7806: <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 7807:
7808: <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484 mike 7809: the document, the user agent must run the following steps:</p>
1.1 mike 7810:
1.484 mike 7811: <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
7812: "interactive" <!-- this also synchronously fires an event --> and
7813: the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
7814:
7815: <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
7816: document has finished parsing</a> is not empty, run these
7817: substeps:</p>
7818:
7819: <ol><li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until the first
7820: <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
7821: execute when the document has finished parsing</a> has its
7822: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
7823: is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
7824: blocking scripts</a>.</p></li>
7825:
7826: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
7827: 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
7828: execute when the document has finished parsing</a>.</p></li>
7829:
7830: <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
7831: <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
7832: finished parsing</a> (i.e. shift out the first entry in the
7833: list).</p></li>
7834:
7835: <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
7836: document has finished parsing</a> is still not empty, repeat
7837: these substeps again from substep 1.</p>
7838:
7839: </li></ol></li>
7840:
7841: <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
7842: scripts that will execute as soon as possible</a> is
7843: empty.</p></li>
7844:
7845: <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
7846: event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
7847: <code>Document</code>.</p></li>
7848:
7849: <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
7850: <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
7851: the <code>Document</code>.</p></li>
7852:
7853: <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
7854: readiness</a> to "complete". <!-- this also fires an event
7855: synchronously during the task --></p></li>
1.1 mike 7856:
1.484 mike 7857: <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
1.1 mike 7858: 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 7859: simple event</a> named <code title="event-load">load</code> at
1.1 mike 7860: the <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
7861: its <code title="dom-event-target">target</code> set to the
7862: <code>Document</code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
1.484 mike 7863: <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1 mike 7864:
1.569 mike 7865: <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
7866: 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
7867: simple event</a> named <code title="event-pageshow">pageshow</code> at the
7868: <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object.</p></li>
7869:
1.484 mike 7870: <li><p>If the <code>Document</code> has a <a href="history.html#pending-state-object">pending state
1.651 mike 7871: 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 at the
1.1 mike 7872: <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object using the
7873: <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
7874: current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484 mike 7875: must bubble but not be cancelable and has no default
7876: action.</p></li>
1.1 mike 7877:
1.484 mike 7878: </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
7879: <a href="browsers.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1 mike 7880:
1.266 mike 7881: </div><div class="impl">
1.1 mike 7882:
1.614 mike 7883: <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 7884:
7885: <p>When an application uses an <a href="#html-parser">HTML parser</a> in
7886: conjunction with an XML pipeline, it is possible that the
7887: constructed DOM is not compatible with the XML tool chain in certain
7888: subtle ways. For example, an XML toolchain might not be able to
7889: represent attributes with the name <code title="">xmlns</code>,
7890: since they conflict with the Namespaces in XML syntax. There is also
7891: some data that the <a href="#html-parser">HTML parser</a> generates that isn't
7892: included in the DOM itself. This section specifies some rules for
7893: handling these issues.</p>
7894:
7895: <p>If the XML API being used doesn't support DOCTYPEs, the tool may
7896: drop DOCTYPEs altogether.</p>
7897:
7898: <p>If the XML API doesn't support attributes in no namespace that
7899: are named "<code title="">xmlns</code>", attributes whose names
7900: start with "<code title="">xmlns:</code>", or attributes in the
7901: <a href="#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
7902: attributes.</p>
7903:
7904: <p>The tool may annotate the output with any namespace declarations
7905: required for proper operation.</p>
7906:
7907: <p>If the XML API being used restricts the allowable characters in
7908: the local names of elements and attributes, then the tool may map
7909: all element and attribute local names that the API wouldn't support
7910: to a set of names that <em>are</em> allowed, by replacing any
7911: character that isn't supported with the uppercase letter U and the
7912: six digits of the character's Unicode code point when expressed in
7913: hexadecimal, using digits 0-9 and capital letters A-F as the
7914: symbols, in increasing numeric order.</p>
7915:
7916: <p class="example">For example, the element name <code title="">foo<bar</code>, which can be output by the <a href="#html-parser">HTML
7917: parser</a>, though it is neither a legal HTML element name nor a
7918: well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
7919: element name (though it's still not legal in HTML by any means).</p>
7920:
7921: <p class="example">As another example, consider the attribute
7922: <code>xlink:href</code>. Used on a MathML element, it becomes, after
7923: being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
7924: attribute with a prefix "<code title="">xlink</code>" and a local
7925: name "<code title="">href</code>". However, used on an HTML element,
7926: it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
7927: might not be accepted by an XML API. It could thus get converted,
7928: becoming "<code title="">xlinkU00003Ahref</code>".</p>
7929:
7930: <p class="note">The resulting names from this conversion
7931: conveniently can't clash with any attribute generated by the
7932: <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
7933: those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
7934: algorithm's table.</p>
7935:
7936: <p>If the XML API restricts comments from having two consecutive
7937: U+002D HYPHEN-MINUS characters (--), the tool may insert a single
7938: U+0020 SPACE character between any such offending characters.</p>
7939:
7940: <p>If the XML API restricts comments from ending in a
7941: U+002D HYPHEN-MINUS character (-), the tool may insert a single
7942: U+0020 SPACE character at the end of such comments.</p>
7943:
7944: <p>If the XML API restricts allowed characters in character data,
1.439 mike 7945: attribute values, or comments, the tool may replace any U+000C FORM
7946: FEED (FF) character with a U+0020 SPACE character, and any other
7947: literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1 mike 7948:
7949: <p>If the tool has no way to convey out-of-band information, then
7950: the tool may drop the following information:</p>
7951:
7952: <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no quirks mode</a></i>,
7953: <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>
7954:
7955: <li>The association between form controls and forms that aren't
7956: their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
7957: <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
7958:
7959: </ul><p class="note">The mutations allowed by this section apply
7960: <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
7961: applied. For example, a <code title=""><a::></code> start tag
7962: will be closed by a <code title=""></a::></code> end tag, and
7963: never by a <code title=""></aU00003AU00003A></code> end tag, even
7964: if the user agent is using the rules above to then generate an
7965: actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
7966:
1.266 mike 7967: </div><div class="impl">
1.1 mike 7968:
1.614 mike 7969: <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 7970:
7971: <p><i>This section is non-normative.</i></p>
7972:
7973: <p>This section examines some erroneous markup and discusses how
7974: the <a href="#html-parser">HTML parser</a> handles these cases.</p>
7975:
7976:
7977: <h5 id="misnested-tags:-b-i-b-i"><span class="secno">9.2.8.1 </span>Misnested tags: <b><i></b></i></h5>
7978:
7979: <p><i>This section is non-normative.</i></p>
7980:
7981: <p>The most-often discussed example of erroneous markup is as
7982: follows:</p>
7983:
7984: <pre><p>1<b>2<i>3</b>4</i>5</p></pre>
7985:
7986: <p>The parsing of this markup is straightforward up to the "3". At
7987: this point, the DOM looks like this:</p>
7988:
1.159 mike 7989: <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
7990: 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 7991: <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
7992: formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
7993: <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>
7994:
7995: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
7996: invoked. This is a simple case, in that the <var title="">formatting
7997: element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
7998: <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159 mike 7999: elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8000: <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 8001: active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
8002: DOM tree is unmodified at this point.</p>
8003:
8004: <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
8005: the active formatting elements</a>, in this case just the
8006: <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
8007: for the "4" text node. After the end tag token for the "i" is also
8008: received, and the "5" text node is inserted, the DOM looks as
8009: follows:</p>
8010:
1.159 mike 8011: <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 8012:
8013: <p><i>This section is non-normative.</i></p>
8014:
8015: <p>A case similar to the previous one is the following:</p>
8016:
8017: <pre><b>1<p>2</b>3</p></pre>
8018:
8019: <p>Up to the "2" the parsing here is straightforward:</p>
8020:
1.159 mike 8021: <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 8022: "b" is parsed.</p>
8023:
8024: <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8025: elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8026: <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 8027: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
8028: <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>
8029:
8030: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
8031: in the previous example. However, in this case, there <em>is</em> a
8032: <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
8033: this time the adoption agency algorithm isn't skipped over.</p>
8034:
1.159 mike 8035: <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 8036: element. A conceptual "bookmark" marks the position of the
8037: <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
8038: elements</a>, but since that list has only one element in it,
8039: it won't have much effect.</p>
8040:
8041: <p>As the algorithm progresses, <var title="">node</var> ends up set
8042: to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
8043: node</var> ends up set to the <var title="">furthest block</var>
8044: (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
8045:
8046: <p>The <var title="">last node</var> gets appended (moved) to the
8047: <var title="">common ancestor</var>, so that the DOM looks like:</p>
8048:
1.159 mike 8049: <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 8050: <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
8051:
1.159 mike 8052: <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 8053: <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
8054:
1.159 mike 8055: <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 8056: active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
8057: elements</a>, so that when the "3" is parsed, it is appended to
8058: the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
8059:
1.614 mike 8060: <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 8061:
8062: <p><i>This section is non-normative.</i></p>
8063:
8064: <p>Error handling in tables is, for historical reasons, especially
8065: strange. For example, consider the following markup:</p>
8066:
8067: <pre><table><strong><b></strong><tr><td>aaa</td></tr><strong>bbb</strong></table>ccc</pre>
8068:
8069: <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
8070: directly inside a table like that, and the parser handles this case
8071: 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
8072: examining the DOM tree as it stands just after the
8073: <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
8074:
1.159 mike 8075: <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 8076: tag has been seen:</p>
8077:
1.159 mike 8078: <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
8079: 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 8080: <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
8081: resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
8082: elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
8083: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
8084: table">in table</a>".</p>
8085:
8086: <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
8087: to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
8088: 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
8089: then handled in a rather straight-forward manner, taking the parser
8090: through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
8091: body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
8092: row</a>" insertion modes, after which the DOM looks as
8093: follows:</p>
8094:
1.159 mike 8095: <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
8096: 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 8097: <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
8098: formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
8099: it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
8100: mode: in row">in row</a>".</p>
8101:
8102: <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
8103: <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
8104: 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
8105: mode</a>).</p>
8106:
1.159 mike 8107: <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 8108: no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
8109: node:</p>
8110:
1.159 mike 8111: <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 8112: handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159 mike 8113: 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 8114: 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
8115: elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
8116: marker having been removed by the "td" end tag token); and the
8117: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
8118: table body">in table body</a>".</p>
8119:
8120: <p>Thus it is that the "bbb" character tokens are found. These
8121: trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
8122: text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
8123: insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
8124: body">in table body</a>"). The character tokens are collected,
8125: and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
8126: seen, they are processed as a group. Since they are not all spaces,
8127: 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,
8128: which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
8129: body</a>" insertion mode but with <a href="#foster-parent" title="foster
8130: parent">foster parenting</a>.</p>
8131:
8132: <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
8133: active formatting elements are reconstructed</a>, a
8134: <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
8135: parent">foster parented</a>, and then the "bbb" text node is
8136: appended to it:</p>
8137:
1.159 mike 8138: <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
8139: <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 8140: <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
8141: this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
8142: formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
8143: and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
8144: mode: in table body">in table body</a>".</p>
8145:
8146: <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
8147: character">space characters</a> instead of "bbb", then those
8148: <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
8149: appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
8150:
8151: <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
8152: tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
8153: elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
8154: but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
8155: elements</a>, so the "ccc" character tokens after the table
8156: result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
8157: time after the table:</p>
8158:
1.614 mike 8159: <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 8160:
8161: <p><i>This section is non-normative.</i></p>
8162:
8163: <p>Consider the following markup, which for this example we will
8164: 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 8165: content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1 mike 8166: <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
8167:
8168: <pre><div id=a>
8169: <script>
8170: var div = document.getElementById('a');
8171: parent.document.body.appendChild(div);
8172: </script>
8173: <script>
8174: alert(document.URL);
8175: </script>
8176: </div>
8177: <script>
8178: alert(document.URL);
8179: </script></pre>
8180:
8181: <p>Up to the first "script" end tag, before the script is parsed,
8182: the result is relatively straightforward:</p>
8183:
1.306 mike 8184: <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="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="">
8185: </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 8186: and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
8187:
1.159 mike 8188: <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 8189: aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
8190: <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306 mike 8191: <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1 mike 8192:
8193: <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
8194: is inserted <em>into the outer <code>Document</code>
8195: object</em>.</p>
8196:
8197: <p>This also means that the <a href="browsers.html#script-s-global-object">script's global object</a> is
8198: the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
8199: object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159 mike 8200: <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1 mike 8201:
8202: <p class="note">This isn't a security problem since the script that
1.306 mike 8203: moves the <code><a href="semantics.html#the-div-element">div</a></code> into the outer <code>Document</code> can
1.1 mike 8204: only do so because they have the two <code>Document</code> object
1.159 mike 8205: have the same <a href="browsers.html#origin">origin</a>.</p>
1.1 mike 8206:
8207: <p>Thus, the first alert says "http://example.com/outer".</p>
8208:
1.306 mike 8209: <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
8210: <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.1 mike 8211: <code><a href="semantics.html#script">script</a></code> element is in the inner <code>Document</code>:</p>
8212:
1.159 mike 8213: <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 8214:
8215:
8216:
1.614 mike 8217: <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 8218:
8219: <p>The <dfn id="html-namespace-0">HTML namespace</dfn> is: <code>http://www.w3.org/1999/xhtml</code></p>
8220:
8221: <p>The <dfn id="mathml-namespace">MathML namespace</dfn> is: <code>http://www.w3.org/1998/Math/MathML</code></p>
8222:
8223: <p>The <dfn id="svg-namespace">SVG namespace</dfn> is: <code>http://www.w3.org/2000/svg</code></p>
8224:
8225: <p>The <dfn id="xlink-namespace">XLink namespace</dfn> is: <code>http://www.w3.org/1999/xlink</code></p>
8226:
8227: <p>The <dfn id="xml-namespace">XML namespace</dfn> is: <code>http://www.w3.org/XML/1998/namespace</code></p>
8228:
8229: <p>The <dfn id="xmlns-namespace">XMLNS namespace</dfn> is: <code>http://www.w3.org/2000/xmlns/</code></p>
8230:
8231: <hr><p>Data mining tools and other user agents that perform operations
1.605 mike 8232: on <code><a href="iana.html#text-html">text/html</a></code> content without running scripts,
1.1 mike 8233: evaluating CSS or XPath expressions, or otherwise exposing the
8234: resulting DOM to arbitrary content, may "support namespaces" by just
8235: asserting that their DOM node analogues are in certain namespaces,
8236: without actually exposing the above strings.</p>
8237:
8238:
8239:
8240:
1.614 mike 8241: <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 8242:
8243: <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
8244: algorithm</dfn>. The algorithm takes as input a DOM
8245: <code>Element</code> or <code>Document</code>, referred to as <var title="">the node</var>, and either returns a string or raises an
8246: exception.</p>
8247:
8248: <p class="note">This algorithm serializes the <em>children</em> of
8249: the node being serialized, not the node itself.</p>
8250:
8251: <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
8252: the empty string.</p></li>
8253:
8254: <li>
8255:
8256: <p>For each child node of <var title="">the node</var>, in
8257: <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
8258:
8259: </p><ol><li><p>Let <var title="">current node</var> be the child node
8260: being processed.</p></li>
8261:
8262: <li>
8263:
8264: <p>Append the appropriate string from the following list to
8265: <var title="">s</var>:</p>
8266:
8267: <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
8268:
8269: <dd>
8270:
1.588 mike 8271: <p>Append a U+003C LESS-THAN SIGN character character (<),
8272: followed by the element's tag name. (For nodes created by the
8273: <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1 mike 8274: lowercase.)</p>
8275:
8276: <p>For each attribute that the element has, append a U+0020
8277: SPACE character, the attribute's name (which, for attributes
8278: 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 8279: U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
8280: character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
8281: <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
8282: character (").</p>
1.1 mike 8283:
8284: <p>While the exact order of attributes is UA-defined, and may
8285: depend on factors such as the order that the attributes were
8286: given in the original markup, the sort order must be stable,
8287: such that consecutive invocations of this algorithm serialize an
8288: element's attributes in the same order.</p>
8289:
1.588 mike 8290: <p>Append a U+003E GREATER-THAN SIGN character (>).</p>
1.1 mike 8291:
8292: <p>If <var title="">current node</var> is an
1.5 mike 8293: <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 8294: <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 8295: <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>,
8296: <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 8297: <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
8298: <code>wbr</code> element, then continue on to the next child
8299: node at this point.</p> <!-- also, i guess: image and isindex,
8300: but we don't list those because we don't consider those
8301: "elements", more "macros", and thus we should never serialize
8302: them -->
1.1 mike 8303:
8304: <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42 mike 8305: <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 8306: a U+000A LINE FEED (LF) character.</p>
8307:
8308: <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
8309: serialization algorithm</a> on the <var title="">current
8310: node</var> element (thus recursing into this algorithm for
1.588 mike 8311: that element), followed by a U+003C LESS-THAN SIGN character
8312: (<), a U+002F SOLIDUS character (/), the element's tag name
8313: again, and finally a U+003E GREATER-THAN SIGN character
8314: (>).</p>
1.1 mike 8315:
8316: </dd>
8317:
8318:
8319: <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
8320: node</dt>
8321:
8322: <dd>
8323:
1.19 mike 8324: <p>If the parent of <var title="">current node</var> is a
1.42 mike 8325: <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 8326: <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 8327: <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
8328: if the parent of <var title="">current node</var> is
8329: <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
8330: node, then append the value of <var title="">current
8331: node</var>'s <code title="">data</code> IDL attribute
8332: literally.</p>
1.1 mike 8333:
8334: <p>Otherwise, append the value of <var title="">current
1.192 mike 8335: node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1 mike 8336: below</a>.</p>
8337:
8338: </dd>
8339:
8340:
8341: <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
8342:
8343: <dd>
8344:
8345: <p>Append the literal string <code><!--</code> (U+003C
8346: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192 mike 8347: U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8348: attribute, followed by the literal string <code>--></code>
8349: (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
8350: SIGN).</p>
8351:
8352: </dd>
8353:
8354:
8355: <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
8356:
8357: <dd>
8358:
8359: <p>Append the literal string <code><?</code> (U+003C
8360: LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192 mike 8361: of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
8362: U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8363: attribute, followed by a single U+003E GREATER-THAN SIGN
1.464 mike 8364: character (>).</p>
1.1 mike 8365:
8366: </dd>
8367:
8368:
8369: <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
8370:
8371: <dd>
8372:
8373: <p>Append the literal string <code><!DOCTYPE</code> (U+003C
8374: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
8375: LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
8376: LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
8377: LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
8378: LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192 mike 8379: value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1 mike 8380: string <code>></code> (U+003E GREATER-THAN SIGN).</p>
8381:
8382: </dd>
8383:
8384:
8385: </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
8386: occur as children of elements. If, despite this, they somehow do
8387: occur, this algorithm must raise an
8388: <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
8389:
8390: </li>
8391:
8392: </ol></li>
8393:
8394: <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
8395:
8396: </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
8397: purposes of the algorithm above) consists of replacing any
8398: occurrences of the "<code title="">&</code>" character by the
8399: string "<code title="">&amp;</code>", any occurrences of the
8400: U+00A0 NO-BREAK SPACE character by the string "<code title="">&nbsp;</code>", and, if the algorithm was invoked in
8401: 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
8402: 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>
8403:
8404: <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
8405: agent, and are therefore not covered in the algorithm above.</p>
8406:
8407: <p class="note">It is possible that the output of this algorithm, if
8408: parsed with an <a href="#html-parser">HTML parser</a>, will not return the
8409: original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
8410: element to which a <code title="">Comment</code> node has been
8411: appended is serialized and the output is then reparsed, the comment
8412: will end up being displayed in the text field. Similarly, if, as a
8413: result of DOM manipulation, an element contains a comment that
8414: contains the literal string "<code title="">--></code>", then
8415: when the result of serializing the element is parsed, the comment
8416: will be truncated at that point and the rest of the comment will be
8417: interpreted as markup. More examples would be making a
8418: <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
8419: "<code></script></code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
8420: 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
8421: <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
8422: tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
8423:
8424:
1.614 mike 8425: <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 8426:
8427: <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
8428: algorithm</dfn>. The algorithm optionally takes as input an
8429: <code>Element</code> node, referred to as the <var title="">context</var> element, which gives the context for the
8430: parser, as well as <var title="">input</var>, a string to parse, and
8431: returns a list of zero or more nodes.</p>
8432:
8433: <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
8434: in the parser section are parts that only occur if the parser was
8435: created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
8436: with such markings for informational purposes only; such markings
8437: have no normative weight. If it is possible for a condition
8438: described as a <a href="#fragment-case">fragment case</a> to occur even when the
8439: parser wasn't created for the purposes of handling this algorithm,
8440: then that is an error in the specification.</p>
8441:
8442: <ol><li>
8443:
8444: <p>Create a new <code>Document</code> node, and mark it as being
8445: an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
8446:
8447: </li>
8448:
8449: <li>
8450:
8451: <p>If there is a <var title="">context</var> element, and the
8452: <code>Document</code> of the <var title="">context</var> element
8453: is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code>Document</code>
8454: 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
8455: the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited quirks
8456: mode</a>, then let the <code>Document</code> be in
8457: <a href="dom.html#limited-quirks-mode">limited quirks mode</a>. Otherwise, leave the
8458: <code>Document</code> in <a href="dom.html#no-quirks-mode">no quirks mode</a>.</p>
8459:
8460: </li>
8461:
8462: <li>
8463:
8464: <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
8465: the just created <code>Document</code> node.</p>
8466:
8467: </li>
8468:
8469: <li>
8470:
8471: <p>If there is a <var title="">context</var> element, run these
8472: substeps:</p>
8473:
8474: <ol><li>
8475:
1.541 mike 8476: <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
8477: <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1 mike 8478:
1.159 mike 8479: <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 8480: element</dt>
8481:
1.541 mike 8482: <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 8483:
8484:
8485: <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 8486: <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 8487: <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1 mike 8488:
1.541 mike 8489: <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 8490:
8491:
8492: <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
8493:
1.541 mike 8494: <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
8495: tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>. Otherwise,
8496: leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8497:
8498:
1.42 mike 8499: <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1 mike 8500:
1.541 mike 8501: <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
8502: state</a>.</dd>
1.1 mike 8503:
8504:
8505: <dt>Otherwise</dt>
8506:
1.541 mike 8507: <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8508:
8509: </dl></li>
8510:
8511: <li>
8512:
1.159 mike 8513: <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 8514: with no attributes.</p>
8515:
8516: </li>
8517:
8518: <li>
8519:
8520: <p>Append the element <var title="">root</var> to the
8521: <code>Document</code> node created above.</p>
8522:
8523: </li>
8524:
8525: <li>
8526:
8527: <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
8528: it contains just the single element <var title="">root</var>.</p>
8529:
8530: </li>
8531:
8532: <li>
8533:
8534: <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
8535: parser's insertion mode appropriately</a>.</p>
8536:
8537: <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
8538:
8539: </li>
8540:
8541: <li>
8542:
8543: <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
8544: to the nearest node to the <var title="">context</var> element
8545: that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
8546: ancestor chain, and including the element itself, if it is a
8547: <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
8548: <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
8549:
8550: </li>
8551:
8552: </ol></li>
8553:
8554: <li>
8555:
8556: <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
8557: parser</a> just created the <var title="">input</var>. The
8558: encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
8559: <i>irrelevant</i>.</p>
8560:
8561: </li>
8562:
8563: <li>
8564:
8565: <p>Start the parser and let it run until it has consumed all the
8566: characters just inserted into the input stream.</p>
8567:
8568: </li>
8569:
8570: <li>
8571:
8572: <p>If there is a <var title="">context</var> element, return the
8573: child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
8574: order</a>.</p>
8575:
8576: <p>Otherwise, return the children of the <code>Document</code>
8577: object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
8578:
8579: </li>
8580:
1.123 mike 8581: </ol></div></body></html>
Webmaster