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