Annotation of html5/spec/syntax.html, revision 1.1250
1.1244 sruby 1: <!DOCTYPE html><html lang="en-US-x-Hixie"><meta charset="utf-8"><title>8 The HTML syntax — HTML5</title><style type="text/css">
2:
3: .applies thead th > * { display: block; }
4: .applies thead code { display: block; }
5: .applies tbody th { white-space: nowrap; }
6: .applies td { text-align: center; }
7: .applies .yes { background: yellow; }
8:
9: .matrix, .matrix td { border: hidden; text-align: right; }
10: .matrix { margin-left: 2em; }
11:
12: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
13: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
14: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
15:
16: td.eg { border-width: thin; text-align: center; }
17:
18: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
19: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
20: #table-example-1 caption { padding-bottom: 0.5em; }
21: #table-example-1 thead, #table-example-1 tbody { border: none; }
22: #table-example-1 th, #table-example-1 td { border: solid thin; }
23: #table-example-1 th { font-weight: normal; }
24: #table-example-1 td { border-style: none solid; vertical-align: top; }
25: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
26: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
27: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
28: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
29: #table-example-1 tbody td:first-child::after { content: leader(". "); }
30: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
31: #table-example-1 tbody td:first-child + td { width: 10em; }
32: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
33: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
34:
35: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
36: .apple-table-examples * { font-family: "Times", serif; }
37: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
38: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
39: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
40: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
41: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
42: .apple-table-examples td { text-align: right; vertical-align: top; }
43: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
44: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
45: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
46: .apple-table-examples sup { line-height: 0; }
47:
48: .details-example img { vertical-align: top; }
49:
50: #base64-table {
51: white-space: nowrap;
52: font-size: 0.6em;
53: column-width: 6em;
54: column-count: 5;
55: column-gap: 1em;
56: -moz-column-width: 6em;
57: -moz-column-count: 5;
58: -moz-column-gap: 1em;
59: -webkit-column-width: 6em;
60: -webkit-column-count: 5;
61: -webkit-column-gap: 1em;
62: }
63: #base64-table thead { display: none; }
64: #base64-table * { border: none; }
65: #base64-table tbody td:first-child:after { content: ':'; }
66: #base64-table tbody td:last-child { text-align: right; }
67:
68: #named-character-references-table {
69: white-space: nowrap;
70: font-size: 0.6em;
71: column-width: 30em;
72: column-gap: 1em;
73: -moz-column-width: 30em;
74: -moz-column-gap: 1em;
75: -webkit-column-width: 30em;
76: -webkit-column-gap: 1em;
77: }
78: #named-character-references-table > table > tbody > tr > td:first-child + td,
79: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
80: #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
81: #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
82:
83: .glyph.control { color: red; }
84:
85: @font-face {
86: font-family: 'Essays1743';
1.1245 sruby 87: src: url('fonts/Essays1743.ttf');
1.1244 sruby 88: }
89: @font-face {
90: font-family: 'Essays1743';
91: font-weight: bold;
1.1245 sruby 92: src: url('fonts/Essays1743-Bold.ttf');
1.1244 sruby 93: }
94: @font-face {
95: font-family: 'Essays1743';
96: font-style: italic;
1.1245 sruby 97: src: url('fonts/Essays1743-Italic.ttf');
1.1244 sruby 98: }
99: @font-face {
100: font-family: 'Essays1743';
101: font-style: italic;
102: font-weight: bold;
1.1245 sruby 103: src: url('fonts/Essays1743-BoldItalic.ttf');
1.1244 sruby 104: }
105:
106: </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20{%20display:%20none;%20}%0Ahtml%20{%20border:%20solid%20yellow;%20}%20.domintro:before%20{%20display:%20none;%20}" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20{%20background:%20%23FFEEEE;%20}%20.domintro:before%20{%20background:%20%23FFEEEE;%20}" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><style type="text/css">
1.1 mike 107: pre { margin-left: 2em; white-space: pre-wrap; }
108: h2 { margin: 3em 0 1em 0; }
109: h3 { margin: 2.5em 0 1em 0; }
110: h4 { margin: 2.5em 0 0.75em 0; }
111: h5, h6 { margin: 2.5em 0 1em; }
112: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
113: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
114: p { margin: 1em 0; }
115: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
116: dl, dd { margin-top: 0; margin-bottom: 0; }
117: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
118: dt + dt { margin-top: 0; }
119: dd dt { margin-top: 0.25em; margin-bottom: 0; }
120: dd p { margin-top: 0; }
121: dd dl + p { margin-top: 1em; }
122: dd table + p { margin-top: 1em; }
123: p + * > li, dd li { margin: 1em 0; }
124: dt, dfn { font-weight: bold; font-style: normal; }
1.1045 mike 125: i, em { font-style: italic; }
1.1 mike 126: dt dfn { font-style: italic; }
127: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
128: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
129: pre em { font-weight: bolder; font-style: normal; }
130: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
131: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
132: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
1.983 mike 133: table thead, table tbody { border-bottom: solid; }
1.1 mike 134: table tbody th:first-child { border-left: solid; }
1.475 mike 135: table tbody th { text-align: left; }
1.1 mike 136: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
137: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
138:
139: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
140: .matrix, .matrix td { border: none; text-align: right; }
141: .matrix { margin-left: 2em; }
142: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
143: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
144: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
145:
146: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
1.1048 mike 147: img.extra, p.overview { float: right; }
1.1047 mike 148: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
1.1 mike 149: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
1.1047 mike 150: pre.idl::before { content: "IDL"; font: bold small sans-serif; padding: 0.5em; background: white; position: absolute; top: 0; margin: -1px 0 0 -4em; width: 1.5em; border: thin solid; border-radius: 0 0 0 0.5em }
1.1 mike 151: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
152: pre.css:first-line { color: #AAAA50; }
1.840 mike 153: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1 mike 154: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
155: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
156: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
157: dl.domintro dd p { margin: 0.5em 0; }
1.1050 mike 158: dl.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
1.1 mike 159: dl.switch { padding-left: 2em; }
160: dl.switch > dt { text-indent: -1.5em; }
161: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
162: dl.triple { padding: 0 0 0 1em; }
163: dl.triple dt, dl.triple dd { margin: 0; display: inline }
164: dl.triple dt:after { content: ':'; }
165: dl.triple dd:after { content: '\A'; white-space: pre; }
166: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
167: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
168: a .diff-new { border-bottom: 1px blue solid; }
169:
1.1232 sruby 170: figure.diagrams { border: double black; background: white; padding: 1em; }
171: figure.diagrams img { display: block; margin: 1em auto; }
172:
1.1 mike 173: h2 { page-break-before: always; }
174: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
175: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
176:
1.1016 mike 177: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
1.1244 sruby 178: li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]) { border-bottom: solid #9999CC; }
1.1 mike 179:
180: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
181: div.head p { margin: 0; }
182: div.head h1 { margin: 0; }
183: div.head .logo { float: right; margin: 0 1em; }
184: div.head .logo img { border: none } /* remove border from top image */
185: div.head dl { margin: 1em 0; }
1.671 mike 186: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1 mike 187:
188: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
189: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
190: body > .toc > li > * { margin-bottom: 0.5em; }
191: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
192: .toc, .toc li { list-style: none; }
193:
194: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
195: .brief li { margin: 0; padding: 0; }
196: .brief li p { margin: 0; padding: 0; }
197:
198: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
199: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
200: .category-list li { display: inline; }
201: .category-list li:not(:last-child)::after { content: ', '; }
202: .category-list li > span, .category-list li > a { text-transform: lowercase; }
203: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
204:
205: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
206: .XXX > :first-child { margin-top: 0; }
207: p .XXX { line-height: 3em; }
1.159 mike 208: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
209: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
210: .annotation :link, .annotation :visited { color: inherit; }
211: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
212: .annotation span { border: none ! important; }
1.1 mike 213: .note { color: green; background: transparent; font-family: sans-serif; }
214: .warning { color: red; background: transparent; }
215: .note, .warning { font-weight: bolder; font-style: italic; }
1.1045 mike 216: .note em, .warning em, .note i, .warning i { font-style: normal; }
1.1 mike 217: p.note, div.note { padding: 0.5em 2em; }
218: span.note { padding: 0 2em; }
219: .note p:first-child, .warning p:first-child { margin-top: 0; }
220: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
221: .warning:before { font-style: normal; }
222: p.note:before { content: 'Note: '; }
223: p.warning:before { content: '\26A0 Warning! '; }
224:
225: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
226: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
227: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
1.1006 mike 228: .bookkeeping dt { margin: 0.5em 2em 0; }
229: .bookkeeping dd { margin: 0 3em 0.5em; }
1.1 mike 230:
231: h4 { position: relative; z-index: 3; }
232: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
233: .element {
234: background: #EEEEFF;
235: color: black;
236: margin: 0 0 1em 0.15em;
237: padding: 0 1em 0.25em 0.75em;
238: border-left: solid #9999FF 0.25em;
239: position: relative;
240: z-index: 1;
241: }
242: .element:before {
243: position: absolute;
244: z-index: 2;
245: top: 0;
246: left: -1.15em;
247: height: 2em;
248: width: 0.9em;
249: background: #EEEEFF;
250: content: ' ';
251: border-style: none none solid solid;
252: border-color: #9999FF;
253: border-width: 0.25em;
254: }
255:
1.149 mike 256: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
257: td > .example:only-child { margin: 0 0 0 0.1em; }
1.1 mike 258:
259: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
260: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
261: ul.domTree li li { list-style: none; }
262: 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; }
263: 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; }
264: ul.domTree span { font-style: italic; font-family: serif; }
265: ul.domTree .t1 code { color: purple; font-weight: bold; }
266: ul.domTree .t2 { font-style: normal; font-family: monospace; }
267: ul.domTree .t2 .name { color: black; font-weight: bold; }
268: ul.domTree .t2 .value { color: blue; font-weight: normal; }
269: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
270: ul.domTree .t7 code, .domTree .t8 code { color: green; }
271: ul.domTree .t10 code { color: teal; }
272:
1.736 mike 273: body.dfnEnabled dfn { cursor: pointer; }
274: .dfnPanel {
275: display: inline;
276: position: absolute;
277: z-index: 10;
278: height: auto;
279: width: auto;
280: padding: 0.5em 0.75em;
281: font: small sans-serif, Droid Sans Fallback;
282: background: #DDDDDD;
283: color: black;
284: border: outset 0.2em;
285: }
286: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
287: .dfnPanel :link, .dfnPanel :visited { color: black; }
288: .dfnPanel p { font-weight: bolder; }
289: .dfnPanel * + p { margin-top: 0.25em; }
290: .dfnPanel li { list-style-position: inside; }
291:
1.671 mike 292: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
293: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
294: #configUI p label { display: block; }
295: #configUI #updateUI, #configUI .loginUI { text-align: center; }
296: #configUI input[type=button] { display: block; margin: auto; }
1.1002 mike 297:
1.1021 mike 298: fieldset { margin: 1em; padding: 0.5em 1em; }
299: fieldset > legend + * { margin-top: 0; }
1.1013 mike 300: fieldset > :last-child { margin-bottom: 0; }
1.1021 mike 301: fieldset p { margin: 0.5em 0; }
302:
1.1246 sruby 303: </style><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css"><script>
1.1033 mike 304: function getCookie(name) {
305: var params = location.search.substr(1).split("&");
306: for (var index = 0; index < params.length; index++) {
307: if (params[index] == name)
308: return "1";
309: var data = params[index].split("=");
310: if (data[0] == name)
311: return unescape(data[1]);
312: }
313: var cookies = document.cookie.split("; ");
314: for (var index = 0; index < cookies.length; index++) {
315: var data = cookies[index].split("=");
316: if (data[0] == name)
317: return unescape(data[1]);
318: }
319: return null;
320: }
1.1244 sruby 321: </script><link href="dnd.html" rel="prev" title="7.7 Drag and drop">
322: <link href="index.html#contents" rel="contents" title="Table of contents">
323: <link href="parsing.html" rel="next" title="8.2 Parsing HTML documents">
324: <body class="split chapter" onload="fixBrokenLink();"><div class="head" id="head">
1.1 mike 325: <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.998 mike 326:
1.183 mike 327: <h1>HTML5</h1>
1.1244 sruby 328: <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.1250 ! sruby 329: <h2 class="no-num no-toc" id="editor's-draft-date-1-january-1970">Editor's Draft 6 November 2012</h2>
1.1244 sruby 330: </div>
331:
1.1242 mike 332:
1.1244 sruby 333: <nav class="prev_next">
334: <a href="dnd.html">← 7.7 Drag and drop</a> –
335: <a href="index.html#contents">Table of contents</a> –
336: <a href="parsing.html">8.2 Parsing HTML documents →</a>
1.996 mike 337: <ol class="toc"><li><a href="syntax.html#syntax"><span class="secno">8 </span>The HTML syntax</a>
338: <ol><li><a href="syntax.html#writing"><span class="secno">8.1 </span>Writing HTML documents</a>
1.1244 sruby 339: <ol><li><a href="syntax.html#the-doctype"><span class="secno">8.1.1 </span>The DOCTYPE</a><li><a href="syntax.html#elements-0"><span class="secno">8.1.2 </span>Elements</a>
340: <ol><li><a href="syntax.html#start-tags"><span class="secno">8.1.2.1 </span>Start tags</a><li><a href="syntax.html#end-tags"><span class="secno">8.1.2.2 </span>End tags</a><li><a href="syntax.html#attributes-0"><span class="secno">8.1.2.3 </span>Attributes</a><li><a href="syntax.html#optional-tags"><span class="secno">8.1.2.4 </span>Optional tags</a><li><a href="syntax.html#element-restrictions"><span class="secno">8.1.2.5 </span>Restrictions on content models</a><li><a href="syntax.html#cdata-rcdata-restrictions"><span class="secno">8.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</a></ol><li><a href="syntax.html#text"><span class="secno">8.1.3 </span>Text</a>
341: <ol><li><a href="syntax.html#newlines"><span class="secno">8.1.3.1 </span>Newlines</a></ol><li><a href="syntax.html#character-references"><span class="secno">8.1.4 </span>Character references</a><li><a href="syntax.html#cdata-sections"><span class="secno">8.1.5 </span>CDATA sections</a><li><a href="syntax.html#comments"><span class="secno">8.1.6 </span>Comments</a></ol></ol></ol></nav>
1.1 mike 342:
1.1136 mike 343: <h2 id="syntax"><span class="secno">8 </span><dfn>The HTML syntax</dfn></h2>
344:
345: <p class="note">This section only describes the rules for resources
1.725 mike 346: labeled with an <a href="infrastructure.html#html-mime-type">HTML MIME type</a>. Rules for XML resources
347: are discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.1136 mike 348: syntax</a>".</p>
349:
350:
351: <h3 id="writing"><span class="secno">8.1 </span>Writing HTML documents</h3>
352:
353: <div class="impl">
1.1 mike 354:
355: <p><i>This section only applies to documents, authoring tools, and
356: markup generators. In particular, it does not apply to conformance
357: checkers; conformance checkers must use the requirements given in
358: the next section ("parsing HTML documents").</i></p>
359:
1.1136 mike 360: </div>
361:
362: <p>Documents must consist of the following parts, in the given
363: order:</p>
364:
365: <ol><li>Optionally, a single "BOM" (U+FEFF) character.</li>
1.1 mike 366:
367: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
1.996 mike 368: <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 369:
370: <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
371:
1.1244 sruby 372: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
1.996 mike 373: <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 374:
1.1052 mike 375: <li>The root element, in the form of an <code><a href="the-html-element.html#the-html-element">html</a></code> <a href="#syntax-elements" title="syntax-elements">element</a>.</li>
1.1 mike 376:
377: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
1.996 mike 378: <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 379:
380: </ol><p>The various types of content mentioned above are described in the
1.1136 mike 381: next few sections.</p>
382:
383: <p>In addition, there are some restrictions on how <a href="the-meta-element.html#character-encoding-declaration" title="character encoding declaration">character encoding
1.1 mike 384: declarations</a> are to be serialized, as discussed in the
1.1136 mike 385: section on that topic.</p>
386:
387: <div class="note">
1.1 mike 388:
1.1052 mike 389: <p>Space characters before the root <code><a href="the-html-element.html#the-html-element">html</a></code> element, and
390: space characters at the start of the <code><a href="the-html-element.html#the-html-element">html</a></code> element and
391: before the <code><a href="the-head-element.html#the-head-element">head</a></code> element, will be dropped when the
1.1 mike 392: document is parsed; space characters <em>after</em> the root
1.1052 mike 393: <code><a href="the-html-element.html#the-html-element">html</a></code> element will be parsed as if they were at the end
394: of the <code><a href="the-body-element.html#the-body-element">body</a></code> element. Thus, space characters around the
1.1 mike 395: root element do not round-trip.</p>
396:
397: <p>It is suggested that newlines be inserted after the DOCTYPE,
398: after any comments that are before the root element, after the
1.1052 mike 399: <code><a href="the-html-element.html#the-html-element">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
400: that are inside the <code><a href="the-html-element.html#the-html-element">html</a></code> element but before the
401: <code><a href="the-head-element.html#the-head-element">head</a></code> element.</p>
1.1 mike 402:
1.1136 mike 403: </div>
404:
405: <p>Many strings in the HTML syntax (e.g. the names of elements and
1.1 mike 406: their attributes) are case-insensitive, but only for characters in
1.547 mike 407: the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
408: LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1 mike 409: LETTER Z). For convenience, in this section this is just referred to
1.1136 mike 410: as "case-insensitive".</p>
411:
412:
413: <h4 id="the-doctype"><span class="secno">8.1.1 </span>The DOCTYPE</h4>
414:
1.1210 sruby 415: <p>A <dfn id="syntax-doctype" title="syntax-doctype">DOCTYPE</dfn> is a <!-- mostly
416: useless but nonetheless --> required preamble.</p>
1.1136 mike 417:
418: <p class="note">DOCTYPEs are required for legacy reasons. When
1.1 mike 419: omitted, browsers tend to use a different rendering mode that is
420: incompatible with some specifications. Including the DOCTYPE in a
421: document ensures that the browser makes a best-effort attempt at
1.1136 mike 422: following the relevant specifications.</p>
423:
424: <p>A DOCTYPE must consist of the following components, in this
425: order:</p>
426:
427: <ol class="brief"><li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title=""><!DOCTYPE</code>".</li>
1.996 mike 428: <li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1011 mike 429: <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">html</code>".</li>
1.861 mike 430: <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> or an <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a> (defined below).</li>
1.996 mike 431: <li>Zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.588 mike 432: <li>A U+003E GREATER-THAN SIGN character (>).</li>
1.1011 mike 433: </ol><p class="note">In other words, <code><!DOCTYPE html></code>,
1.1136 mike 434: case-insensitively.</p>
435:
436: <hr><p>For the purposes of HTML generators that cannot output HTML
1.1 mike 437: markup with the short DOCTYPE "<code title=""><!DOCTYPE
1.1011 mike 438: html></code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
1.1 mike 439: into the DOCTYPE (in the position defined above). This string must
1.1136 mike 440: consist of:</p>
441:
442: <ol class="brief"><li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 443: <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.996 mike 444: <li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 445: <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.1047 mike 446: <li>The literal string "<code><a href="urls.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.856 mike 447: <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>quote mark</i>).</li>
1.1011 mike 448: </ol><p class="note">In other words, <code><!DOCTYPE html SYSTEM
449: "about:legacy-compat"></code> or <code><!DOCTYPE html SYSTEM
1.1004 mike 450: 'about:legacy-compat'></code>, case-insensitively except for the
1.1136 mike 451: part in single or double quotes.</p>
452:
453: <p>The <a href="#doctype-legacy-string">DOCTYPE legacy string</a> should not be used unless
1.1 mike 454: the document is generated from a system that cannot output the
1.1136 mike 455: shorter string.</p>
456:
1.1210 sruby 457: <hr><!-- see the parser section before changing this bit --><p>To help authors transition from HTML4 and XHTML1, an
1.861 mike 458: <dfn id="obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</dfn> can be inserted into
459: the DOCTYPE (in the position defined above). This string must
1.1136 mike 460: consist of:</p>
461:
462: <ol class="brief"><li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.861 mike 463: <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">PUBLIC</code>".</li>
1.996 mike 464: <li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.861 mike 465: <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>first quote mark</i>).</li>
466: <li>The string from one of the cells in the first column of the table below. The row to which this cell belongs is the <i>selected row</i>.</li>
467: <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>first quote mark</i>).</li>
1.996 mike 468: <li>If the cell in the second column of the <i>selected row</i> is not blank, one or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.861 mike 469: <li>If the cell in the second column of the <i>selected row</i> is not blank, a U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>third quote mark</i>).</li>
470: <li>If the cell in the second column of the <i>selected row</i> is not blank, the string from the cell in the second column of the <i>selected row</i>.</li>
471: <li>If the cell in the second column of the <i>selected row</i> is not blank, a matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>third quote mark</i>).</li>
472: </ol><table><caption>
473: Allowed values for public and system identifiers in an <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a>.
474: </caption>
475: <thead><tr><th> Public identifier
1.1244 sruby 476: <th> System identifier
477: <tbody><tr><td> <code title="">-//W3C//DTD HTML 4.0//EN</code>
478: <td>
479: <tr><td> <code title="">-//W3C//DTD HTML 4.0//EN</code>
480: <td> <code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>
481: <tr><td> <code title="">-//W3C//DTD HTML 4.01//EN</code>
482: <td>
483: <tr><td> <code title="">-//W3C//DTD HTML 4.01//EN</code>
484: <td> <code title="">http://www.w3.org/TR/html4/strict.dtd</code>
485: <tr><td> <code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>
486: <td> <code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>
487: <tr><td> <code title="">-//W3C//DTD XHTML 1.1//EN</code>
488: <td> <code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>
489: </table><p>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a> containing an
1.861 mike 490: <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a> is an <dfn id="obsolete-permitted-doctype">obsolete
491: permitted DOCTYPE</dfn>. Authors should not use <a href="#obsolete-permitted-doctype" title="obsolete permitted DOCTYPE">obsolete permitted
1.1136 mike 492: DOCTYPEs</a>, as they are unnecessarily long.</p>
493:
494:
495:
496:
497: <h4 id="elements-0"><span class="secno">8.1.2 </span>Elements</h4>
498:
499: <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 500: <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
1.1136 mike 501: <a href="#foreign-elements">foreign elements</a>, and <a href="#normal-elements">normal elements</a>.</p>
502:
503: <dl><dt><dfn id="void-elements">Void elements</dfn></dt>
1.1 mike 504:
1.1052 mike 505: <dd><code><a href="the-area-element.html#the-area-element">area</a></code>, <code><a href="the-base-element.html#the-base-element">base</a></code>, <code><a href="the-br-element.html#the-br-element">br</a></code>,
506: <code><a href="the-col-element.html#the-col-element">col</a></code>, <code><a href="the-command-element.html#the-command-element">command</a></code>, <code><a href="the-embed-element.html#the-embed-element">embed</a></code>,
507: <code><a href="the-hr-element.html#the-hr-element">hr</a></code>, <code><a href="the-img-element.html#the-img-element">img</a></code>, <code><a href="the-input-element.html#the-input-element">input</a></code>,
508: <code><a href="the-keygen-element.html#the-keygen-element">keygen</a></code>, <code><a href="the-link-element.html#the-link-element">link</a></code>, <code><a href="the-meta-element.html#the-meta-element">meta</a></code>,
509: <code><a href="the-param-element.html#the-param-element">param</a></code>, <code><a href="the-source-element.html#the-source-element">source</a></code>, <code><a href="the-track-element.html#the-track-element">track</a></code>,
510: <code><a href="the-wbr-element.html#the-wbr-element">wbr</a></code></dd>
1.1210 sruby 511: <!-- see also other places that say VOIDLIST -->
1.1 mike 512:
1.373 mike 513: <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1 mike 514:
1.1210 sruby 515: <dd><code><a href="the-script-element.html#the-script-element">script</a></code>, <code><a href="the-style-element.html#the-style-element">style</a></code></dd> <!-- iframe and
516: noscript don't count as raw text for syntax purposes -->
1.1055 mike 517:
1.373 mike 518: <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1 mike 519:
1.1052 mike 520: <dd><code><a href="the-textarea-element.html#the-textarea-element">textarea</a></code>, <code><a href="the-title-element.html#the-title-element">title</a></code></dd>
1.1 mike 521:
1.373 mike 522: <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1 mike 523:
1.1047 mike 524: <dd>Elements from the <a href="namespaces.html#mathml-namespace">MathML namespace</a>
525: and the <a href="namespaces.html#svg-namespace">SVG namespace</a>.</dd>
1.1 mike 526:
1.373 mike 527: <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1 mike 528:
529: <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
530: elements.</dd>
531:
532: </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373 mike 533: and end of elements in the markup. <a href="#raw-text-elements" title="raw text
534: elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
535: elements">RCDATA</a>, and <a href="#normal-elements" title="normal
536: elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
537: begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
538: indicate where they end. The start and end tags of certain
539: <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 540: later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
541: elements</a> only have a start tag; end tags must not be
1.373 mike 542: specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
543: elements</a> must either have a start tag and an end tag, or a
544: start tag that is marked as self-closing, in which case they must
1.1136 mike 545: not have an end tag.</p>
546:
547: <p>The contents of the element must be placed between just after the
1.1 mike 548: start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
549: in certain cases</a>) and just before the end tag (which again,
550: <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
551: cases</a>). The exact allowed contents of each individual element
1.1004 mike 552: depend on the content model of that element, as described earlier in
553: this specification. Elements must not contain content that their
1.1 mike 554: content model disallows. In addition to the restrictions placed on
555: the contents by those content models, however, the five types of
1.1136 mike 556: elements have additional <em>syntactic</em> requirements.</p>
557:
558: <p><a href="#void-elements">Void elements</a> can't have any contents (since there's
1.1 mike 559: no end tag, no content can be put between the start tag and the end
1.1136 mike 560: tag).</p>
561:
562: <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
563: below.</p>
564:
565: <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
1.373 mike 566: must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1 mike 567: There are also <a href="#cdata-rcdata-restrictions">further
1.1136 mike 568: restrictions</a> described below.</p>
569:
570: <p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
1.373 mike 571: self-closing can't have any contents (since, again, as there's no
572: end tag, no content can be put between the start tag and the end
573: tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
574: 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.1136 mike 575: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p>
576:
577: <div class="note">
1.374 mike 578:
579: <p>The HTML syntax does not support namespace
580: declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
581:
582: <p>For instance, consider the following HTML fragment:</p>
583:
584: <pre><p>
585: <svg>
586: <metadata>
587: <!-- this is invalid -->
588: <cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/>
589: </metadata>
590: </svg>
591: </p></pre>
592:
593: <p>The innermost element, <code title="">cdr:license</code>, is
594: actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
595: XML). In fact, as the comment in the fragment above says, the
596: fragment is actually non-conforming. This is because the SVG
597: specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
598:
1.1136 mike 599: </div>
600:
601: <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 602: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
603: <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1 mike 604: content they are allowed to hold, beyond the restrictions imposed by
605: the content model and those described in this paragraph. Those
1.1136 mike 606: restrictions are described below.</p>
607:
608: <p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1 mike 609: giving the element's name. HTML elements all have names that only
1.1212 sruby 610: use characters in the range <a href="common-microsyntaxes.html#ascii-digits">ASCII digits</a>, <a href="common-microsyntaxes.html#lowercase-ascii-letters">lowercase ASCII letters</a>, and <a href="common-microsyntaxes.html#uppercase-ascii-letters">uppercase ASCII letters</a>. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462 mike 611: elements</a>, may be written with any mix of lower- and uppercase
612: letters that, when converted to all-lowercase, matches the element's
1.1136 mike 613: tag name; tag names are case-insensitive.</p>
614:
615:
616: <h5 id="start-tags"><span class="secno">8.1.2.1 </span>Start tags</h5>
617:
618: <p><dfn id="syntax-start-tag" title="syntax-start-tag">Start tags</dfn> must have the
619: following format:</p>
620:
621: <ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588 mike 622: SIGN character (<).</li>
1.1 mike 623:
624: <li>The next few characters of a start tag must be the element's
625: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
626:
627: <li>If there are to be any attributes in the next step, there must
1.996 mike 628: first be one or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1 mike 629: characters</a>.</li>
630:
631: <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
1.1004 mike 632: below. Attributes must be separated from each other by one or more
1.996 mike 633: <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 634:
1.766 mike 635: <li>After the attributes, or after the <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a> if there are no attributes,
1.996 mike 636: there may be one or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.766 mike 637: characters</a>. (Some attributes are required to be followed by
638: a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes
639: section</a> below.)</li>
1.1 mike 640:
641: <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373 mike 642: or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588 mike 643: element</a>, then there may be a single U+002F SOLIDUS character
644: (/). This character has no effect on <a href="#void-elements">void elements</a>,
645: but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
646: self-closing.</li>
1.1 mike 647:
648: <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588 mike 649: SIGN character (>).</li>
1.1 mike 650:
1.1136 mike 651: </ol><h5 id="end-tags"><span class="secno">8.1.2.2 </span>End tags</h5>
652:
653: <p><dfn id="syntax-end-tag" title="syntax-end-tag">End tags</dfn> must have the
654: following format:</p>
655:
656: <ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588 mike 657: SIGN character (<).</li>
1.1 mike 658:
1.1136 mike 659: <li>The second character of an end tag must be a "/" (U+002F) character.</li>
1.1 mike 660:
661: <li>The next few characters of an end tag must be the element's
662: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
663:
1.996 mike 664: <li>After the tag name, there may be one or more <a href="common-microsyntaxes.html#space-character" title="space
1.1 mike 665: character">space characters</a>.</li>
666:
1.588 mike 667: <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
668: character (>).</li>
1.1 mike 669:
1.1136 mike 670: </ol><h5 id="attributes-0"><span class="secno">8.1.2.3 </span>Attributes</h5>
671:
672: <p><dfn id="syntax-attributes" title="syntax-attributes">Attributes</dfn> for an element
673: are expressed inside the element's start tag.</p>
674:
675: <p>Attributes have a name and a value. <dfn id="syntax-attribute-name" title="syntax-attribute-name">Attribute names</dfn> must consist of
1.996 mike 676: one or more characters other than the <a href="common-microsyntaxes.html#space-character" title="space
1.1210 sruby 677: character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
678: MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
1.1136 mike 679: (>), "/" (U+002F), and "=" (U+003D) characters,
1.1 mike 680: the control characters, and any characters that are not defined by
1.462 mike 681: Unicode. In the HTML syntax, attribute names, even those for
682: <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
683: and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.1136 mike 684: case-insensitive</a> match for the attribute's name.</p>
685:
686: <p><dfn id="syntax-attribute-value" title="syntax-attribute-value">Attribute values</dfn> are a
1.1 mike 687: 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.1136 mike 688: additional restriction that the text cannot contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p>
689:
690: <p>Attributes can be specified in four different ways:</p>
691:
692: <dl><dt>Empty attribute syntax</dt>
1.1 mike 693:
694: <dd>
695:
696: <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
1.837 mike 697: name</a>. The value is implicitly the empty string.</p>
1.1 mike 698:
699: <div class="example">
700:
1.1052 mike 701: <p>In the following example, the <code title="attr-fe-disabled"><a href="attributes-common-to-form-controls.html#attr-fe-disabled">disabled</a></code> attribute is given with
1.1 mike 702: the empty attribute syntax:</p>
703:
704: <pre><input <em>disabled</em>></pre>
705:
706: </div>
707:
708: <p>If an attribute using the empty attribute syntax is to be
1.996 mike 709: followed by another attribute, then there must be a <a href="common-microsyntaxes.html#space-character">space
1.1 mike 710: character</a> separating the two.</p>
711:
712: </dd>
713:
1.2 mike 714: <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1 mike 715:
716: <dd>
717:
718: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
1.996 mike 719: followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1 mike 720: characters</a>, followed by a single U+003D EQUALS SIGN
1.996 mike 721: character, followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space
1.1 mike 722: character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
723: addition to the requirements given above for attribute values,
1.996 mike 724: must not contain any literal <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1210 sruby 725: characters</a>, any U+0022 QUOTATION MARK characters ("),
726: U+0027 APOSTROPHE characters ('), "=" (U+003D) characters, U+003C LESS-THAN SIGN characters (<), U+003E
1.1136 mike 727: GREATER-THAN SIGN characters (>), or "`" (U+0060) characters, and must not be the empty string.</p>
1.463 mike 728:
1.1210 sruby 729: <!-- The ` character is in this list on a temporary basis, waiting
730: for IE to fix its parsing bug whereby it treats ` as an
731: attribute value delimiter. Otherwise, escaping software that
732: tries to be clever and not use quotes when it doesn't need to
733: could be tricked by an attacker.
734:
735: Posit a site that allows the user to input text that is used
736: verbatim in two attributes, such that the user can set the
737: first attribute's value to:
738:
739: `
740:
741: ...and the second to:
742:
743: ` onload='...payload...' end=x
744:
745: ...with the assumption that the site is going to not quote
746: the first one, and quote the second one with double quotes:
747:
748: <body title=` class="` onload='...payload...' end=x">
749:
750: In IE, this is treated as:
751:
752: <body title=' class="'
753: onload='...payload...'
754: end='x"'>
755:
756: -->
1.1 mike 757:
1.1055 mike 758:
1.1 mike 759: <div class="example">
760:
1.1047 mike 761: <p>In the following example, the <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> attribute is given
1.1 mike 762: with the unquoted attribute value syntax:</p>
763:
764: <pre><input <em>value=yes</em>></pre>
765:
766: </div>
767:
768: <p>If an attribute using the unquoted attribute syntax is to be
1.1136 mike 769: followed by another attribute or by the optional "/" (U+002F) character allowed in step 6 of the <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> syntax above, then there
1.996 mike 770: must be a <a href="common-microsyntaxes.html#space-character">space character</a> separating the two.</p>
1.1 mike 771:
772: </dd>
773:
774: <dt>Single-quoted attribute value syntax</dt>
775:
776: <dd>
777:
778: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
1.996 mike 779: followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1 mike 780: characters</a>, followed by a single U+003D EQUALS SIGN
1.996 mike 781: character, followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space
1.1136 mike 782: character">space characters</a>, followed by a single "'" (U+0027) character, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 783: addition to the requirements given above for attribute values,
1.1136 mike 784: must not contain any literal "'" (U+0027) characters, and
1.588 mike 785: finally followed by a second single U+0027 APOSTROPHE character
786: (').</p>
1.1 mike 787:
788: <div class="example">
789:
1.1047 mike 790: <p>In the following example, the <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute is given with the
1.1 mike 791: single-quoted attribute value syntax:</p>
792:
793: <pre><input <em>type='checkbox'</em>></pre>
794:
795: </div>
796:
797: <p>If an attribute using the single-quoted attribute syntax is to
1.996 mike 798: be followed by another attribute, then there must be a <a href="common-microsyntaxes.html#space-character">space
1.1 mike 799: character</a> separating the two.</p>
800:
801: </dd>
802:
803: <dt>Double-quoted attribute value syntax</dt>
804:
805: <dd>
806:
807: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
1.996 mike 808: followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1 mike 809: characters</a>, followed by a single U+003D EQUALS SIGN
1.996 mike 810: character, followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space
1.1136 mike 811: character">space characters</a>, followed by a single """ (U+0022) character, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 812: addition to the requirements given above for attribute values,
1.1136 mike 813: must not contain any literal """ (U+0022) characters,
814: and finally followed by a second single """ (U+0022) character.</p>
1.1 mike 815:
816: <div class="example">
817:
1.1052 mike 818: <p>In the following example, the <code title="attr-fe-name"><a href="attributes-common-to-form-controls.html#attr-fe-name">name</a></code> attribute is given with the
1.1 mike 819: double-quoted attribute value syntax:</p>
820:
821: <pre><input <em>name="be evil"</em>></pre>
822:
823: </div>
824:
825: <p>If an attribute using the double-quoted attribute syntax is to
1.996 mike 826: be followed by another attribute, then there must be a <a href="common-microsyntaxes.html#space-character">space
1.1 mike 827: character</a> separating the two.</p>
828:
829: </dd>
830:
831: </dl><p>There must never be two or more attributes on the same start tag
832: whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.1136 mike 833: each other.</p>
834:
835: <hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
1.462 mike 836: one of the namespaced attributes given by the local name and
837: namespace of the first and second cells of a row from the following
838: table, it must be written using the name given by the third cell
1.1136 mike 839: from the same row.</p>
840:
1.1244 sruby 841: <table><thead><tr><th> Local name <th> Namespace <th> Attribute name
842: <tbody><tr><td> <code title="">actuate</code> <td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> <td> <code title="">xlink:actuate</code>
843: <tr><td> <code title="">arcrole</code> <td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> <td> <code title="">xlink:arcrole</code>
844: <tr><td> <code title="">href</code> <td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> <td> <code title="">xlink:href</code>
845: <tr><td> <code title="">role</code> <td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> <td> <code title="">xlink:role</code>
846: <tr><td> <code title="">show</code> <td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> <td> <code title="">xlink:show</code>
847: <tr><td> <code title="">title</code> <td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> <td> <code title="">xlink:title</code>
848: <tr><td> <code title="">type</code> <td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> <td> <code title="">xlink:type</code>
849: <tr><td> <code title="">base</code> <td> <a href="namespaces.html#xml-namespace">XML namespace</a> <!-- attr-xml-base --> <td> <code title="">xml:base</code>
850: <tr><td> <code title="">lang</code> <td> <a href="namespaces.html#xml-namespace">XML namespace</a> <td> <code title="">xml:lang</code>
851: <tr><td> <code title="">space</code> <td> <a href="namespaces.html#xml-namespace">XML namespace</a> <td> <code title="">xml:space</code>
852: <tr><td> <code title="">xmlns</code> <td> <a href="namespaces.html#xmlns-namespace">XMLNS namespace</a> <td> <code title="">xmlns</code>
853: <tr><td> <code title="">xlink</code> <td> <a href="namespaces.html#xmlns-namespace">XMLNS namespace</a> <td> <code title="">xmlns:xlink</code>
854: </table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.1136 mike 855: HTML syntax</a>.</p>
856:
1.1235 sruby 857: <p class="note">Whether the attributes in the table above are
858: conforming or not is defined by other specifications (e.g. the SVG
859: and MathML specifications); this section only describes the syntax
860: rules if the attributes are serialised using the HTML syntax.</p>
861:
1.1136 mike 862:
863: <h5 id="optional-tags"><span class="secno">8.1.2.4 </span>Optional tags</h5>
864:
865: <p>Certain tags can be <dfn id="syntax-tag-omission" title="syntax-tag-omission">omitted</dfn>.</p>
866:
867: <p class="note">Omitting an element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> in the situations
1.1045 mike 868: described below does not mean the element is not present; it is
869: implied, but it is still there. For example, an HTML document always
1.1136 mike 870: has a root <code><a href="the-html-element.html#the-html-element">html</a></code> element, even if the string <code title=""><html></code> doesn't appear anywhere in the markup.</p>
871:
1.1210 sruby 872: <!-- <html> -->
1.1136 mike 873: <p>An <code><a href="the-html-element.html#the-html-element">html</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
874: first thing inside the <code><a href="the-html-element.html#the-html-element">html</a></code> element is not a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p>
875:
1.1210 sruby 876: <!-- </html> -->
1.1136 mike 877: <p>An <code><a href="the-html-element.html#the-html-element">html</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 878: tag</a> may be omitted if the <code><a href="the-html-element.html#the-html-element">html</a></code> element is not
1.1136 mike 879: immediately followed by a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p>
880:
1.1210 sruby 881: <!-- <head> -->
1.1136 mike 882: <p>A <code><a href="the-head-element.html#the-head-element">head</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
1.821 mike 883: element is empty, or if the first thing inside the
1.1136 mike 884: <code><a href="the-head-element.html#the-head-element">head</a></code> element is an element.</p>
885:
1.1210 sruby 886: <!-- </head> -->
1.1136 mike 887: <p>A <code><a href="the-head-element.html#the-head-element">head</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 888: tag</a> may be omitted if the <code><a href="the-head-element.html#the-head-element">head</a></code> element is not
1.1136 mike 889: immediately followed by a <a href="common-microsyntaxes.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p>
890:
1.1210 sruby 891: <!-- <body> -->
1.1136 mike 892: <p>A <code><a href="the-body-element.html#the-body-element">body</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
1.1052 mike 893: element is empty, or if the first thing inside the <code><a href="the-body-element.html#the-body-element">body</a></code>
1.996 mike 894: element is not a <a href="common-microsyntaxes.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>, except if the first thing
1.1052 mike 895: inside the <code><a href="the-body-element.html#the-body-element">body</a></code> element is a <code><a href="the-script-element.html#the-script-element">script</a></code> or
1.1210 sruby 896: <code><a href="the-style-element.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
897: tag is present, the parser makes <style> and <script> elements
898: between </head> and <body> end up in the <head> instead of implying
899: the <body> --></p>
1.1136 mike 900:
1.1210 sruby 901: <!-- </body> -->
1.1136 mike 902: <p>A <code><a href="the-body-element.html#the-body-element">body</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 903: tag</a> may be omitted if the <code><a href="the-body-element.html#the-body-element">body</a></code> element is not
1.1136 mike 904: immediately followed by a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p>
905:
1.1210 sruby 906: <!-- </li> -->
1.1136 mike 907: <p>An <code><a href="the-li-element.html#the-li-element">li</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 908: tag</a> may be omitted if the <code><a href="the-li-element.html#the-li-element">li</a></code> element is
909: immediately followed by another <code><a href="the-li-element.html#the-li-element">li</a></code> element or if there
1.1136 mike 910: is no more content in the parent element.</p>
911:
1.1210 sruby 912: <!-- </dt> -->
1.1136 mike 913: <p>A <code><a href="the-dt-element.html#the-dt-element">dt</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 914: tag</a> may be omitted if the <code><a href="the-dt-element.html#the-dt-element">dt</a></code> element is
915: immediately followed by another <code><a href="the-dt-element.html#the-dt-element">dt</a></code> element or a
1.1136 mike 916: <code><a href="the-dd-element.html#the-dd-element">dd</a></code> element.</p>
917:
1.1210 sruby 918: <!-- </dd> -->
1.1136 mike 919: <p>A <code><a href="the-dd-element.html#the-dd-element">dd</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 920: tag</a> may be omitted if the <code><a href="the-dd-element.html#the-dd-element">dd</a></code> element is
921: immediately followed by another <code><a href="the-dd-element.html#the-dd-element">dd</a></code> element or a
922: <code><a href="the-dt-element.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.1136 mike 923: parent element.</p>
924:
1.1210 sruby 925: <!-- </p> -->
1.1136 mike 926: <p>A <code><a href="the-p-element.html#the-p-element">p</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 927: tag</a> may be omitted if the <code><a href="the-p-element.html#the-p-element">p</a></code> element is
928: immediately followed by an <code><a href="the-address-element.html#the-address-element">address</a></code>,
929: <code><a href="the-article-element.html#the-article-element">article</a></code>, <code><a href="the-aside-element.html#the-aside-element">aside</a></code>, <code><a href="the-blockquote-element.html#the-blockquote-element">blockquote</a></code>,
930: <code><a href="obsolete.html#dir">dir</a></code>, <code><a href="the-div-element.html#the-div-element">div</a></code>, <code><a href="the-dl-element.html#the-dl-element">dl</a></code>,
931: <code><a href="the-fieldset-element.html#the-fieldset-element">fieldset</a></code>, <code><a href="the-footer-element.html#the-footer-element">footer</a></code>, <code><a href="the-form-element.html#the-form-element">form</a></code>,
1.1210 sruby 932: <code><a href="the-aside-element.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h1</a></code>, <code><a href="the-aside-element.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h2</a></code>, <code><a href="the-aside-element.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h3</a></code>, <code><a href="the-aside-element.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h4</a></code>,
933: <code><a href="the-aside-element.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h5</a></code>, <code><a href="the-aside-element.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements">h6</a></code>, <code><a href="the-header-element.html#the-header-element">header</a></code>,
1.1052 mike 934: <code><a href="the-hgroup-element.html#the-hgroup-element">hgroup</a></code>, <code><a href="the-hr-element.html#the-hr-element">hr</a></code>, <code><a href="the-menu-element.html#the-menu-element">menu</a></code>,
935: <code><a href="the-nav-element.html#the-nav-element">nav</a></code>, <code><a href="the-ol-element.html#the-ol-element">ol</a></code>, <code><a href="the-p-element.html#the-p-element">p</a></code>, <code><a href="the-pre-element.html#the-pre-element">pre</a></code>,
936: <code><a href="the-section-element.html#the-section-element">section</a></code>, <code><a href="the-table-element.html#the-table-element">table</a></code>, or <code><a href="the-ul-element.html#the-ul-element">ul</a></code>,
1.1 mike 937: element, or if there is no more content in the parent element and
1.1136 mike 938: the parent element is not an <code><a href="the-a-element.html#the-a-element">a</a></code> element.</p>
939:
1.1210 sruby 940: <!-- </rt> -->
1.1136 mike 941: <p>An <code><a href="the-rt-element.html#the-rt-element">rt</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 942: tag</a> may be omitted if the <code><a href="the-rt-element.html#the-rt-element">rt</a></code> element is
943: immediately followed by an <code><a href="the-rt-element.html#the-rt-element">rt</a></code> or <code><a href="the-rp-element.html#the-rp-element">rp</a></code>
1.1136 mike 944: element, or if there is no more content in the parent element.</p>
945:
1.1210 sruby 946: <!-- </rp> -->
1.1136 mike 947: <p>An <code><a href="the-rp-element.html#the-rp-element">rp</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 948: tag</a> may be omitted if the <code><a href="the-rp-element.html#the-rp-element">rp</a></code> element is
949: immediately followed by an <code><a href="the-rt-element.html#the-rt-element">rt</a></code> or <code><a href="the-rp-element.html#the-rp-element">rp</a></code>
1.1136 mike 950: element, or if there is no more content in the parent element.</p>
951:
1.1210 sruby 952: <!-- </optgroup> (the text assumes <optgroup> can only be inside a
953: <select>; commented out text below can handle the non-<select> case
954: if we ever allow it) -->
1.1136 mike 955: <p>An <code><a href="the-optgroup-element.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.1210 sruby 956: <code><a href="the-optgroup-element.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
957: <code>select</code> element and--> is immediately followed by
958: another <code><a href="the-optgroup-element.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
959: that are ancestors of the <code>optgroup</code> element, up to and
960: including the first ancestor element that is not an
961: <code>optgroup</code> element, have no more content--> there is no
1.1136 mike 962: more content in the parent element.</p>
1.1210 sruby 963: <!-- so e.g. the max number of </optgroup>s are omitted here:
964: <select><optgroup></select>
965: <p id=x><optgroup></optgroup>x</p>
966: <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
967: <p><optgroup id=x><optgroup></optgroup>x</p>
968: <p><optgroup><optgroup id=x>x</p>
969: -->
1.1136 mike 970:
1.1210 sruby 971: <!-- </option> -->
1.1136 mike 972: <p>An <code><a href="the-option-element.html#the-option-element">option</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 973: tag</a> may be omitted if the <code><a href="the-option-element.html#the-option-element">option</a></code> element is
974: immediately followed by another <code><a href="the-option-element.html#the-option-element">option</a></code> element, or if
975: it is immediately followed by an <code><a href="the-optgroup-element.html#the-optgroup-element">optgroup</a></code> element, or
1.1136 mike 976: if there is no more content in the parent element.</p>
977:
1.1210 sruby 978: <!-- <colgroup> -->
1.1136 mike 979: <p>A <code><a href="the-colgroup-element.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.1052 mike 980: first thing inside the <code><a href="the-colgroup-element.html#the-colgroup-element">colgroup</a></code> element is a
981: <code><a href="the-col-element.html#the-col-element">col</a></code> element, and if the element is not immediately
982: preceded by another <code><a href="the-colgroup-element.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.1136 mike 983: omitted if the element is empty.)</p>
984:
1.1210 sruby 985: <!-- </colgroup> -->
1.1136 mike 986: <p>A <code><a href="the-colgroup-element.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.1052 mike 987: <code><a href="the-colgroup-element.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.1136 mike 988: <a href="common-microsyntaxes.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p>
989:
1.1210 sruby 990: <!-- </thead> -->
1.1136 mike 991: <p>A <code><a href="the-thead-element.html#the-thead-element">thead</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 992: tag</a> may be omitted if the <code><a href="the-thead-element.html#the-thead-element">thead</a></code> element is
993: immediately followed by a <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code> or <code><a href="the-tfoot-element.html#the-tfoot-element">tfoot</a></code>
1.1136 mike 994: element.</p>
995:
1.1210 sruby 996: <!-- <tbody> -->
1.1136 mike 997: <p>A <code><a href="the-tbody-element.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.1052 mike 998: first thing inside the <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code> element is a
999: <code><a href="the-tr-element.html#the-tr-element">tr</a></code> element, and if the element is not immediately
1000: preceded by a <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code>, <code><a href="the-thead-element.html#the-thead-element">thead</a></code>, or
1001: <code><a href="the-tfoot-element.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1 mike 1002: tag</a> has been omitted. (It can't be omitted if the element is
1.1136 mike 1003: empty.)</p>
1004:
1.1210 sruby 1005: <!-- </tbody> -->
1.1136 mike 1006: <p>A <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 1007: tag</a> may be omitted if the <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code> element is
1008: immediately followed by a <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code> or <code><a href="the-tfoot-element.html#the-tfoot-element">tfoot</a></code>
1.1136 mike 1009: element, or if there is no more content in the parent element.</p>
1010:
1.1210 sruby 1011: <!-- </tfoot> -->
1.1136 mike 1012: <p>A <code><a href="the-tfoot-element.html#the-tfoot-element">tfoot</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 1013: tag</a> may be omitted if the <code><a href="the-tfoot-element.html#the-tfoot-element">tfoot</a></code> element is
1014: immediately followed by a <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code> element, or if there is
1.1136 mike 1015: no more content in the parent element.</p>
1016:
1.1210 sruby 1017: <!-- </tr> -->
1.1136 mike 1018: <p>A <code><a href="the-tr-element.html#the-tr-element">tr</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 1019: tag</a> may be omitted if the <code><a href="the-tr-element.html#the-tr-element">tr</a></code> element is
1020: immediately followed by another <code><a href="the-tr-element.html#the-tr-element">tr</a></code> element, or if there
1.1136 mike 1021: is no more content in the parent element.</p>
1022:
1.1210 sruby 1023: <!-- </td> -->
1.1136 mike 1024: <p>A <code><a href="the-td-element.html#the-td-element">td</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 1025: tag</a> may be omitted if the <code><a href="the-td-element.html#the-td-element">td</a></code> element is
1026: immediately followed by a <code><a href="the-td-element.html#the-td-element">td</a></code> or <code><a href="the-th-element.html#the-th-element">th</a></code>
1.1136 mike 1027: element, or if there is no more content in the parent element.</p>
1028:
1.1210 sruby 1029: <!-- </th> -->
1.1136 mike 1030: <p>A <code><a href="the-th-element.html#the-th-element">th</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1052 mike 1031: tag</a> may be omitted if the <code><a href="the-th-element.html#the-th-element">th</a></code> element is
1032: immediately followed by a <code><a href="the-td-element.html#the-td-element">td</a></code> or <code><a href="the-th-element.html#the-th-element">th</a></code>
1.1136 mike 1033: element, or if there is no more content in the parent element.</p>
1034:
1035: <p><strong>However</strong>, a <a href="#syntax-start-tag" title="syntax-start-tag">start
1036: tag</a> must never be omitted if it has any attributes.</p>
1037:
1038:
1039: <h5 id="element-restrictions"><span class="secno">8.1.2.5 </span>Restrictions on content models</h5>
1040:
1041: <p>For historical reasons, certain elements have extra restrictions
1042: beyond even the restrictions given by their content model.</p>
1043:
1044: <p>A <code><a href="the-table-element.html#the-table-element">table</a></code> element must not contain <code><a href="the-tr-element.html#the-tr-element">tr</a></code>
1.1 mike 1045: elements, even though these elements are technically allowed inside
1.1052 mike 1046: <code><a href="the-table-element.html#the-table-element">table</a></code> elements according to the content models
1047: described in this specification. (If a <code><a href="the-tr-element.html#the-tr-element">tr</a></code> element is
1048: put inside a <code><a href="the-table-element.html#the-table-element">table</a></code> in the markup, it will in fact imply
1.1136 mike 1049: a <code><a href="the-tbody-element.html#the-tbody-element">tbody</a></code> start tag before it.)</p>
1050:
1051: <p>A single <a href="#syntax-newlines" title="syntax-newlines">newline</a> may be
1.304 mike 1052: placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1052 mike 1053: tag</a> of <code><a href="the-pre-element.html#the-pre-element">pre</a></code> and <code><a href="the-textarea-element.html#the-textarea-element">textarea</a></code>
1.1 mike 1054: elements. This does not affect the processing of the element. The
1.304 mike 1055: otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381 mike 1056: <em>must</em> be included if the element's contents themselves start
1057: with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
1058: otherwise the leading newline in the contents would be treated like
1.1136 mike 1059: the optional newline, and ignored).</p>
1060:
1061: <div class="example">
1.1052 mike 1062: <p>The following two <code><a href="the-pre-element.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
1.1 mike 1063: <pre><pre>Hello</pre></pre>
1064: <pre><pre><br>Hello</pre></pre>
1.1136 mike 1065: </div>
1066:
1067:
1068: <h5 id="cdata-rcdata-restrictions"><span class="secno">8.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5>
1069:
1070: <p>The text in <a href="#raw-text-elements" title="raw text elements">raw text</a> and
1.889 mike 1071: <a href="#rcdata-elements">RCDATA elements</a> must not contain any occurrences of the
1072: string "<code title=""></</code>" (U+003C LESS-THAN SIGN, U+002F
1073: SOLIDUS) followed by characters that case-insensitively match the
1.1210 sruby 1074: tag name of the element followed by one of "tab" (U+0009), "LF" (U+000A), "FF" (U+000C), "CR" (U+000D), U+0020 SPACE, ">" (U+003E), or
1.1136 mike 1075: "/" (U+002F).</p>
1076:
1077:
1.1210 sruby 1078: <h4 id="text"><span class="secno">8.1.3 </span>Text</h4>
1.1136 mike 1079:
1080: <p><dfn id="syntax-text" title="syntax-text">Text</dfn> is allowed inside elements,
1.1108 mike 1081: attribute values, and comments. Extra constraints are placed on what
1082: is and what is not allowed in text based on where the text is to be
1.1136 mike 1083: put, as described in the other sections.</p>
1084:
1085:
1086: <h5 id="newlines"><span class="secno">8.1.3.1 </span>Newlines</h5>
1087:
1088: <p><dfn id="syntax-newlines" title="syntax-newlines">Newlines</dfn> in HTML may be
1089: represented either as "CR" (U+000D) characters, "LF" (U+000A) characters, or pairs of "CR" (U+000D),
1090: "LF" (U+000A) characters in that order.</p>
1091:
1092: <p>Where <a href="#syntax-charref" title="syntax-charref">character references</a>
1093: are allowed, a character reference of a "LF" (U+000A)
1094: character (but not a "CR" (U+000D) character) also
1095: represents a <a href="#syntax-newlines" title="syntax-newlines">newline</a>.</p>
1096:
1097:
1098: <h4 id="character-references"><span class="secno">8.1.4 </span>Character references</h4>
1099:
1100: <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 1101: to escape characters that couldn't otherwise legally be included in
1.1136 mike 1102: <a href="#syntax-text" title="syntax-text">text</a>.</p>
1103:
1104: <p>Character references must start with a U+0026 AMPERSAND character
1.588 mike 1105: (&). Following this, there are three possible kinds of character
1.1136 mike 1106: references:</p>
1107:
1108: <dl><dt>Named character references</dt>
1.1 mike 1109:
1110: <dd>The ampersand must be followed by one of the names given in the
1111: <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677 mike 1112: case. <span class="impl">The name must be one that is terminated by
1.1136 mike 1113: a ";" (U+003B) character.</span></dd>
1.1 mike 1114:
1115:
1116: <dt>Decimal numeric character reference</dt>
1117:
1.1212 sruby 1118: <dd>The ampersand must be followed by a "#" (U+0023) character, followed by one or more digits in the range <a href="common-microsyntaxes.html#ascii-digits">ASCII digits</a>, representing a base-ten
1.588 mike 1119: integer that corresponds to a Unicode code point that is allowed
1120: according to the definition below. The digits must then be followed
1.1136 mike 1121: by a ";" (U+003B) character.</dd>
1.1 mike 1122:
1123:
1124: <dt>Hexadecimal numeric character reference</dt>
1125:
1.1136 mike 1126: <dd>The ampersand must be followed by a "#" (U+0023) character, which must be followed by either a "x" (U+0078) character or a "X" (U+0058) character, which must then be followed by one or more digits in
1.1212 sruby 1127: the range <a href="common-microsyntaxes.html#ascii-digits">ASCII digits</a>, U+0061
1.588 mike 1128: LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
1129: LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464 mike 1130: representing a base-sixteen integer that corresponds to a Unicode
1131: code point that is allowed according to the definition below. The
1132: digits must then be followed by a U+003B SEMICOLON character
1133: (;).</dd>
1.378 mike 1134:
1135: </dl><p>The numeric character reference forms described above are allowed
1.882 mike 1136: to reference any Unicode code point other than U+0000, U+000D,
1137: permanently undefined Unicode characters (noncharacters), and
1.996 mike 1138: control characters other than <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1136 mike 1139: characters</a>.</p>
1140:
1141: <p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464 mike 1142: ampersand</dfn> is a U+0026 AMPERSAND character (&) that is
1.1212 sruby 1143: followed by one or more characters in the range <a href="common-microsyntaxes.html#ascii-digits">ASCII digits</a>, <a href="common-microsyntaxes.html#lowercase-ascii-letters">lowercase ASCII letters</a>, and <a href="common-microsyntaxes.html#uppercase-ascii-letters">uppercase ASCII letters</a>, followed by a U+003B SEMICOLON character
1.897 mike 1144: (;), where these characters do not match any of the names given in
1.1136 mike 1145: the <a href="named-character-references.html#named-character-references">named character references</a> section.</p>
1146:
1147:
1148: <h4 id="cdata-sections"><span class="secno">8.1.5 </span>CDATA sections</h4>
1149:
1150: <p><dfn id="syntax-cdata" title="syntax-cdata">CDATA sections</dfn> must consist of
1151: the following components, in this order:</p>
1152:
1153: <ol><li>The string "<code title=""><![CDATA[</code>".</li>
1.1029 mike 1154:
1155: <li>Optionally, <a href="#syntax-text" title="syntax-text">text</a>, with the
1156: additional restriction that the text must not contain the string
1157: "<code title="">]]></code>".</li>
1158:
1159: <li>The string "<code title="">]]></code>".</li>
1160:
1161: </ol><div class="example">
1.724 mike 1162:
1163: <p>CDATA sections can only be used in foreign content (MathML or
1164: SVG). In this example, a CDATA section is used to escape the
1165: contents of an <code>ms</code> element:</p>
1166:
1167: <pre><p>You can add a string to a number, but this stringifies the number:</p>
1168: <math>
1169: <ms><![CDATA[x<y]]></ms>
1170: <mo>+</mo>
1171: <mn>3</mn>
1172: <mo>=</mo>
1173: <ms><![CDATA[x<y3]]></ms>
1174: </math></pre>
1175:
1.1136 mike 1176: </div>
1177:
1178:
1179: <h4 id="comments"><span class="secno">8.1.6 </span>Comments</h4>
1180:
1181: <p><dfn id="syntax-comments" title="syntax-comments">Comments</dfn> must start with the
1.1 mike 1182: four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
1183: MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title=""><!--</code>). Following this sequence, the comment may
1184: have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
1185: restriction that the text must not start with a single U+003E
1.1136 mike 1186: GREATER-THAN SIGN character (>), nor start with a "-" (U+002D) character followed by a U+003E GREATER-THAN SIGN
1.588 mike 1187: (>) character, nor contain two consecutive U+002D HYPHEN-MINUS
1.1136 mike 1188: characters (<code title="">--</code>), nor end with a "-" (U+002D) character. Finally, the comment must be ended by
1.1 mike 1189: the three character sequence U+002D HYPHEN-MINUS, U+002D
1.1136 mike 1190: HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p>
1191:
1192:
1.1244 sruby 1193:
Webmaster