index.html
64.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<title>Polyglot Markup: HTML-Compatible XHTML Documents</title>
<meta name="GENERATOR" content="MSHTML 8.00.7600.16588"/>
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD"/>
<style type="text/css">
.stability {
text-align:center;
position: fixed;
bottom: 0;
left: 0; right: 0;
margin: 0 auto 0 auto;
width: 50%;
background: maroon; color: yellow;
-webkit-border-radius: 1em 1em 0 0;
-moz-border-radius: 1em 1em 0 0;
border-radius: 1em 1em 0 0;
-moz-box-shadow: 0 0 1em #500;
-webkit-box-shadow: 0 0 1em #500;
box-shadow: 0 0 1em red;
padding: 0.5em 1em;
}
.stability a {
color:white;
}
.stability a:visited {
color:silver
}
.stability input {
background-color:silver;
float:right;
font-size:x-small;
font-weight:bold;
}
</style>
</head>
<body style="display: inherit;">
<div class="head">
<p>
<a href="http://www.w3.org/"><img height="48" width="72" alt="W3C" src="http://www.w3.org/Icons/w3c_home"/></a>
</p>
<h1 class="title" id="title">Polyglot Markup: HTML-Compatible XHTML Documents</h1>
<h2 id="w3c-working-draft-25-may-2011">W3C Working Draft 25 May 2011</h2>
<dl>
<dt>This version:</dt>
<dd><a href="http://www.w3.org/TR/2011/WD-html-polyglot-20110525/">http://www.w3.org/TR/2011/WD-html-polyglot-20110525/</a></dd>
<dt>Latest published version:</dt>
<dd><a href="http://www.w3.org/TR/html-polyglot/">http://www.w3.org/TR/html-polyglot/</a></dd>
<dt>Latest editor's draft:</dt>
<dd><a href="http://dev.w3.org/html5/html-xhtml-author-guide/">http://dev.w3.org/html5/html-xhtml-author-guide/</a></dd>
<dt>Previous versions:</dt>
<dd><a href="http://www.w3.org/TR/2011/WD-html-polyglot-20110405/">http://www.w3.org/TR/2011/WD-html-polyglot-20110405/</a></dd>
<dd><a href="http://www.w3.org/TR/2011/WD-html-polyglot-20110113/">http://www.w3.org/TR/2011/WD-html-polyglot-20110113/</a></dd>
<dd><a href="http://www.w3.org/TR/2010/WD-html-polyglot-20100624/">http://www.w3.org/TR/2010/WD-html-polyglot-20100624/</a></dd>
<dd><a href="http://www.w3.org/TR/2010/WD-html-polyglot-20101019/">http://www.w3.org/TR/2010/WD-html-polyglot-20101019/</a></dd>
<dt>Editor:</dt>
<dd><span>Eliot Graff</span>, Microsoft Corporation</dd>
</dl>
<p class="copyright">
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2011
<a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
<a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
<a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
</p>
</div>
<hr/>
<div class="introductory section" id="abstract">
<h2>Abstract</h2>
A document that uses polyglot markup is a document that is a stream of bytes that parses into identical document trees
(with the exception of the xmlns attribute on the root element) when processed as HTML and when processed as XML.
Polyglot markup that meets a well defined set of constraints is interpreted as compatible, regardless of whether they are processed as HTML or as XHTML, per the HTML5 specification.
Polyglot markup uses a specific DOCTYPE, namespace declarations, and a specific case—normally lower case but occasionally camel case—for element and attribute names.
Polyglot markup uses lower case for certain attribute values.
Further constraints include those on empty elements, named entity references, and the use of scripts and style.
<!--End of Abstract-->
</div>
<div id="sotd" class="introductory section">
<h2>Status of This Document</h2>
<p>
<em>This section describes the status of this document at the time of its publication.
Other documents may supersede this document.
A list of current W3C publications and the latest revision of this technical report can be found in the
<a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.</em>
</p>
<p>
This document summarizes design guidelines for authors who wish their XHTML or HTML documents to validate on either HTML or XML parsers,
assuming the parsers to be HTML5-compliant. This specification is intended to be used by web authors.
It is not a specification for user agents and creates no obligations on user agents.
Note that this recommendation does not define how HTML5-conforming user agents should process HTML documents.
Nor does it define the meaning of the Internet Media Type text/html.
For user agent guidance and for these definitions, see [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>] and
[<cite><a href="#bib-RFC2854" rel="biblioentry" class="bibref">RFC2854</a></cite>].
</p>
<p>
This document was published by the <a href="http://www.w3.org/html/wg/">HTML working group</a> as a Last Call Working Draft.
This document is intended to become a W3C Recommendation.
The Last Call period ends 03 August 2011.
Please submit comments regarding this document by using the W3C's public bug database (<a href="http://www.w3.org/Bugs/Public/">
http://www.w3.org/Bugs/Public/</a>) with the product set to <kbd>HTML WG</kbd> and the component set to
<kbd>HTML/XHTML Compatibility Authoring Guide (ed: Eliot Graff)</kbd>.
If you cannot access the bug database, submit comments to <a href="mailto:public-html-comments@w3.org">public-html-comments@w3.org</a>
(<a href="mailto:public-html-comments-request@w3.org?subject=subscribe">subscribe</a>,
<a href="http://lists.w3.org/Archives/Public/public-html-comments/">archives</a>) and arrangements will be made to transpose the comments to the bug database.
All feedback is welcome.
</p>
<p>
Publication as a Working Draft does not imply endorsement by the W3C Membership.
This is a draft document and may be updated, replaced or obsoleted by other documents at any time.
It is inappropriate to cite this document as other than work in progress.
</p>
<p>A formal objection is open against this document:
<a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=12725">bug 12725 (Document should be on the Note-track)</a>.</p>
<p>W3C anticipates that there will be changes to this specification as a
result of the resolution of Last Call issues. Per the usual W3C Process,
any significant changes to the specification will trigger a subsequent Last
Call.</p>
<p>
This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/40318/status" rel="disclosure">public list of any patent disclosures</a>
made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has
actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a>
must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.
</p>
<p class="stability" id="wip">
<input onclick="closeWarning(this.parentNode)" type="button" value="X"/>
<strong>This is a work in progress!</strong>
<br/>
For the latest updates from the HTML WG, possibly including important bug fixes,
<br/>
please look at the <a href="http://dev.w3.org/html5/html-xhtml-author-guide/">editor's draft</a> instead.
There may also be a more
<a href="http://www.w3.org/TR/html-polyglot/">up-to-date Working Draft</a>
with changes based on
resolution of Last Call issues.
</p>
<script type="text/javascript" class="all-pages">
function closeWarning(element)
{
element.parentNode.removeChild(element);
}
</script>
<!--End of Status of This Document-->
</div>
<!-- TOC -->
<div class="section" id="toc">
<h2 class="introductory">Table of Contents</h2>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#introduction"><span class="secno">1. </span>Introduction</a></li>
<li class="tocline"><a class="tocxref" href="#PI-and-xml"><span class="secno">2. </span>Processing Instructions and the XML Declaration</a></li>
<li class="tocline"><a class="tocxref" href="#character-encoding"><span class="secno">3. </span>Specifying a Document's Character Encoding</a></li>
<li class="tocline"><a class="tocxref" href="#doctype"><span class="secno">4. </span>The DOCTYPE</a></li>
<li class="tocline"><a class="tocxref" href="#namespaces"><span class="secno">5. </span>Namespaces</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#element-level-namespaces"><span class="secno">5.1 </span>Element-Level Namespaces</a></li>
<li class="tocline"><a class="tocxref" href="#attribute-level-namespaces"><span class="secno">5.2 </span>Attribute-Level Namespaces</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#elements"><span class="secno">6. </span>Elements</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#required-elements"><span class="secno">6.1 </span>Required Elements</a></li>
<li class="tocline"><a class="tocxref" href="#elements-that-cannot-be-used"><span class="secno">6.2 </span>Elements that Cannot Be Used in Polyglot Markup</a></li>
<li class="tocline"><a class="tocxref" href="#case-sensitivity"><span class="secno">6.3 </span>Case-Sensitivity</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#element-names"><span class="secno">6.3.1 </span>Element Names</a></li>
<li class="tocline"><a class="tocxref" href="#attribute-names"><span class="secno">6.3.2 </span>Attribute Names</a></li>
<li class="tocline"><a class="tocxref" href="#attribute-values"><span class="secno">6.3.3 </span>Attribute Values</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#empty-elements"><span class="secno">6.4 </span>Void Elements</a></li>
<li class="tocline"><a class="tocxref" href="#elements-with-special-considerations"><span class="secno">6.5 </span>Elements with Special Considerations</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#http-headers-and-http-equiv"><span class="secno">6.5.1 </span>HTTP Headers and http-equiv Declarations</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#content-language"><span class="secno">6.5.1.1 </span>Content-Language</a></li>
<li class="tocline"><a class="tocxref" href="#content-type"><span class="secno">6.5.1.2 </span>Content-Type</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#newlines-in-textarea-and-pre"><span class="secno">6.5.2 </span>Newlines in <code>textarea</code> and <code>pre</code> Elements</a></li>
</ul>
</li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#attributes"><span class="secno">7. </span>Attributes</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#disallowed-attributes"><span class="secno">7.1 </span>Disallowed Attributes</a></li>
<li class="tocline"><a class="tocxref" href="#language-attributes"><span class="secno">7.2 </span>Language Attributes</a></li>
<li class="tocline"><a class="tocxref" href="#attributes-with-special-considerations"><span class="secno">7.3 </span>Attributes with Special Considerations</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#id-attribute"><span class="secno">7.3.1 </span>The <code>id</code> Attribute</a></li>
</ul>
</li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#named-entity-references"><span class="secno">8. </span>Named Entity References</a></li>
<li class="tocline"><a class="tocxref" href="#script-and-style"><span class="secno">9. </span>Script and Style</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#external-script-and-style"><span class="secno">9.1 </span>External Script and Style</a></li>
<li class="tocline"><a class="tocxref" href="#in-line-script-and-style"><span class="secno">9.2 </span>In-line Script and Style</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#comments"><span class="secno">10. </span>Comments in Polyglot Markup</a></li>
<li class="tocline"><a class="tocxref" href="#foreign-content"><span class="secno">11. </span>Exceptions from the Foreign Content Parsing Rules</a></li>
<li class="tocline"><a class="tocxref" href="#example-document"><span class="secno">12. </span>Example Document</a></li>
<li class="tocline"><a class="tocxref" href="#acknowledgements"><span class="secno">A. </span>Acknowledgements</a></li>
<li class="tocline"><a class="tocxref" href="#references"><span class="secno">B. </span>References</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#normative-references"><span class="secno">B.1 </span>Normative references</a></li>
<li class="tocline"><a class="tocxref" href="#informative-references"><span class="secno">B.2 </span>Informative references</a></li>
</ul>
</li>
</ul>
</div>
<!-- End TOC -->
<div id="introduction" class="section informative">
<!--OddPage--><h2><span class="secno">1. </span>Introduction</h2><p><em>This section is non-normative.</em></p>
<p>
It is often valuable to be able to serve HTML5 documents that are also well formed XML documents.
An author may, for example, use XML tools to generate a document, and they and others may process the document using XML tools.
The language used to create documents that can be parsed by both HTML and XML parsers is called <dfn id="dfn-polyglot-markup">polyglot markup</dfn>.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> is
the overlap language of documents that are both HTML5 documents and XML documents.
It is recommended that these documents be served as either <code>text/html</code> (if the content is transmitted to an HTML-aware user agent)
or <code>application/xhtml+xml</code> (if the content is transmitted to an XHTML-aware user agent).
Other permissible MIME types are <code>text/xml</code>, <code>application/xml</code>,
and any MIME type whose subtype ends with the four characters "<code>+xml</code>". [<cite><a href="#bib-XML-MT" rel="biblioentry" class="bibref">XML-MT</a></cite>]
</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> results in:
</p>
<ul>
<li>a valid HTML document. [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>]</li>
<li>
a <a href="http://www.w3.org/TR/2008/PER-xml-20080205/#sec-well-formed">well-formed XML</a> document.
[<cite><a href="#bib-XML10" rel="biblioentry" class="bibref">XML10</a></cite>]
</li>
<li>
identical DOMs when processed as HTML and when processed as XML.
A noteable exception to this is that HTML and XML parsers generate different DOMs for
some <code>xml</code> (<code>xml:lang</code>, <code>xml:space</code>, and <code>xml:base</code>),
<code>xmlns</code> (<code>xmlns=""</code> and <code>xmlns:xlink=""</code>), and <code>xlink</code> (such as <code>xlink:href</code>) attributes.
XML requires and HTML5 permits these attributes in certain locations and the attributes are preserved by HTML parsers.
</li>
</ul>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> is not constrained:
</p>
<ul>
<li>
to be <a href="http://www.w3.org/TR/2008/PER-xml-20080205/#dt-valid">valid XML</a>.
[<cite><a href="#bib-XML10" rel="biblioentry" class="bibref">XML10</a></cite>]
</li>
<li>by conformance to any XML DTD.</li>
</ul>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> is
scripted according to the rules of XML (does not use <code>document.write</code>, for example)
and excludes HTML elements that are impossible to replicate in an XML parser (does not use the <code>noscript</code> element, for example).
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> triggers non-quirks mode in HTML parsers,
as non-quirks mode is closest to XML-mode rendering, in regard to both DOM and CSS.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> results in
the same encoding and the same language in both HTML-mode and XML-mode.
</p>
<p>
All web content need not be authored in <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> is ideal for publishing when
there's a strong desire to serve both HTML and XML tool chains
without simultaneously having to maintain dual copies of the content: one in HTML and a second in XHTML.
In addition, a single <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> output requires
less infrastructure to produce than to produce both HTML and XHTML output for the same content.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> is also be beneficial when lightweight processes—such as
quick testing or even hand-authoring—are applied to content intended to be published both as HTML and XHTML,
especially if that content is not sent through a tool chain.
</p>
<!--End section: Introduction-->
</div>
<div id="PI-and-xml" class="section">
<!--OddPage--><h2><span class="secno">2. </span>Processing Instructions and the XML Declaration</h2>
<p>
Processing Instructions and the XML Declaration are both forbidden in <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
</p>
<!--End section: Processing Instructions and the XML Declaration-->
</div>
<div id="character-encoding" class="section">
<!--OddPage--><h2><span class="secno">3. </span>Specifying a Document's Character Encoding</h2>
<p>
Polyglot markup uses the UTF-8 character encoding, the only character encoding for which both HTML and XML require support.
HTML requires UTF-8 to be explicitly declared to avoid <a href="http://www.w3.org/TR/html5/semantics.html#charset">fallback to a legacy encoding</a> [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>].
For XML, UTF-8 is an <a href="http://www.w3.org/TR/2008/REC-xml-20081126/#charencoding">encoding default</a>.
As such, character encoding <em title="may" class="rfc2119">may</em> be left undeclared in XML with the result that UTF-8 is still supported [<cite><a href="#bib-XML10" rel="biblioentry" class="bibref">XML10</a></cite>].
</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> declares the UTF-8 character encoding in the following ways, which may be used separately or in combination:
</p>
<ul>
<li>Within the document
<ul>
<li>By using the Byte Order Mark (BOM) character (preferred).</li>
<li>By using <code><meta charset="UTF-8"/></code> (the HTML encoding declaration).</li>
</ul>
</li>
<li>Outside the document
<ul>
<li>By adding <code>"charset=utf-8"</code> to the MIME/HTTP Content-Type header [<cite><a href="#bib-HTTP11" rel="biblioentry" class="bibref">HTTP11</a></cite>], as the following examples show in HTML and XML, respectively: </li>
</ul>
<pre class="example"><code>Content-type: text/html; charset=utf-8</code></pre>
<pre class="example"><code>Content-type: application/xhtml+xml; charset=utf-8</code></pre>
</li>
</ul>
<p class="note">
The HTML encoding declaration has no effect in XML.
When the HTML encoding declaration is the only encoding declaration,
the encoding default from XML makes XML parsers treat content as UTF-8.
</p>
<p>
The <a href="http://www.w3.org/International/questions/qa-html-encoding-declarations">W3C Internationalization (i18n) Group recommends</a>
to always include
a visible encoding declaration in a document, because it helps
developers, testers, or translation production managers to check the
encoding of a document visually.
</p>
<!--End section: Specifying a Document's Character Encoding-->
</div>
<div id="doctype" class="section">
<!--OddPage--><h2><span class="secno">4. </span>The DOCTYPE</h2>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses a document type declaration (DOCTYPE) specified by <a href="http://www.w3.org/TR/html5/syntax.html#the-doctype">section 8.1.1</a> of [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>].
In addition, the DOCTYPE conforms to the following rules:
</p>
<ul>
<li>The string <code>DOCTYPE</code> is in uppercase letters.</li>
<li>The string <code>html</code> is in lowercase letters.</li>
<li>The string <code>SYSTEM</code>, if present, is in uppercase letters.</li>
<li>The string <code>PUBLIC</code>, if present, is in uppercase letters.</li>
<li>A Formal Public Identifier (FPI), if present, is a case-sensitive match of the registered FPI to which it points.</li>
<li>A URI, if present in the document type declaration, is a case-sensitive match of the URI to which it points.
<ul>
<li>If the URI is the string <code>about:legacy-compat</code>, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> includes the string in lowercase letters, as required by HTML5.</li>
<li>If the URI is an http URL, the URI points to the correct resource, using case-sensitive letters.</li>
</ul>
</li>
</ul>
<p>
Note that using <code>about:legacy-compat</code> in XML may yield unpredictable parsing results, depending on the XML processing pipeline.
</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not use document type declarations for HTML4, HTML3, or HTML2, regardless of whether they contain a URI or not and
regardless of their effect in HTML5 parsers, as these document type declarations are not compatible with XHTML.
</p>
<!--End section: The DOCTYPE-->
</div>
<div id="namespaces" class="section">
<!--OddPage--><h2><span class="secno">5. </span>Namespaces</h2>
<p>
The following rules apply to namespaces used in <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
</p>
<div id="element-level-namespaces" class="section">
<h3><span class="secno">5.1 </span>Element-Level Namespaces</h3>
<p>
[<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>] introduces undeclared (native) default namespaces for the root HTML element, <code>html</code>, the root SVG element, <code>svg</code>,
and the root MathML element, <code>math</code>.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a>
declares the following default namespaces, when the markup languages
are included in the document, to maintain XML-compatibility [<cite><a href="#bib-XML10" rel="biblioentry" class="bibref">XML10</a></cite>]:
</p><ul>
<li><code><html xmlns="http://www.w3.org/1999/xhtml"></code></li>
<li><code><math xmlns="http://www.w3.org/1998/Math/MathML"></code></li>
<li><code><svg xmlns="http://www.w3.org/2000/svg"></code></li>
</ul>
<p></p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> declares the default namespaces on the root HTML element, <code>html</code>,
the root SVG element, <code>svg</code>, and the root MathML element <code>math</code>,
and on any HTML elements used as children of SVG or MathML elements.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not declare any other default or prefixed element namespace, because
[<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>] does not natively support the declaring of any other default or prefixed element namespace.
</p>
<!-- End section, "Element-Level Namespaces" -->
</div>
<div id="attribute-level-namespaces" class="section">
<h3><span class="secno">5.2 </span>Attribute-Level Namespaces</h3>
<p>
[<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>] introduces undeclared (native) support for attributes in the XLink namespace and with the prefix <code>xlink:</code>.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> declares the XLink namespace on the HTML root element (<code>html</code>) or
once on the foreign element where it is used (<code>svg</code> or <code>math</code>), to maintain XML-compatibility [<cite><a href="#bib-XML10" rel="biblioentry" class="bibref">XML10</a></cite>].
</p>
<p>In <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>, the xlink prefix uses the namespace declaration <code>xmlns:xlink="http://www.w3.org/1999/xlink"</code> before using the xlink prefix for the following attributes:
</p><ul>
<li><code>xlink:actuate</code></li>
<li><code>xlink:arcrole</code></li>
<li><code>xlink:href</code></li>
<li><code>xlink:role</code></li>
<li><code>xlink:show</code></li>
<li><code>xlink:title</code></li>
<li><code>xlink:type</code></li>
</ul>
Furthermore, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> defines the xlink prefix only on foreign elements (any SVG or MathML element) but not the root <code>html</code> element or any other HTML element.
<p></p>
<p>
Note that there are other prefixed attributes that can be used beyond <code>xlink:href</code> (such as <code>xml:base</code>).
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not declare these prefixes via xmlns. The prefixes are implicitly declared in XML and are automatically
applied to the appropriate attributes in HTML.
</p>
<!-- End section, "Attribute-Level Namespaces" -->
</div>
<!--End section: Namespaces-->
</div>
<div id="elements" class="section">
<!--OddPage--><h2><span class="secno">6. </span>Elements</h2>
<p><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> conforms to the following rules regarding elements.</p>
<div id="required-elements" class="section">
<h3><span class="secno">6.1 </span>Required Elements</h3>
<p>
Every <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> document contains an <code>html</code>, <code>head</code>, <code>title</code>,
and <code>body</code> element.
The <code>html</code> element is the root element.
The <code>head</code> and <code>body</code> elements are children of the <code>html</code> element.
The <code>title</code> element is a child of the <code>head</code> element.
Therefore, the following source code would be the most basic <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> document.
</p>
<pre class="example"><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<title></title>
</head>
<body>
</body>
</html></pre>
<p>
Whenever it uses a <code>tr</code> element, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> always wraps the <code>tr</code> element inside a
<code>tbody</code>, <code>thead</code>, or <code>tfoot</code> element.
In HTML, if a group of one or more adjacent <code>tr</code> elements are not explictly wrapped inside a <code>tbody</code>, <code>thead</code>, or <code>tfoot</code> element,
the HTML parser creates and wraps a new <code>tbody</code> element around the <code>tr</code> elements.
XML parsers do not create the <code>tbody</code> element, thus offering the potential for creating different DOMs.
</p>
<p>
Correct:
</p>
<pre class="example"><table>
<tbody>
<tr>...</pre>
Incorrect:
<pre class="example"><table>
<tr>...</pre>
<p>
Whenever it uses <code>col</code> elements within a <code>table</code> element, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> explicitly uses a <code>colgroup</code> element surrounding groups of the <code>col</code> elements.
In HTML, if a group of one or more adjacent <code>col</code> elements are not explicitly wrapped inside a <code>colgroup</code> element,
the HTML parser creates and wraps a new <code>colgroup</code> element around the <code>col</code> elements.
XML parsers do not create the <code>colgroup</code> element, thus offering the potential for creating different DOMs.
</p>
<p>
Correct:
</p>
<pre class="example"><table>
<colgroup>
<col>...</pre>
Incorrect:
<pre class="example"><table>
<col>...</pre>
</div>
<div id="elements-that-cannot-be-used" class="section">
<h3><span class="secno">6.2 </span>Elements that Cannot Be Used in Polyglot Markup</h3>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not use the <code>noscript</code> element, because
the <code>noscript</code> element cannot be used in XML documents. [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>]
</p>
<!--End section: Elements that Cannot Be Used in Polyglot Markup-->
</div>
<div id="case-sensitivity" class="section">
<h3><span class="secno">6.3 </span>Case-Sensitivity</h3>
<p>
The following guidelines apply to any usage of element names, attribute names, or attribute values in markup, script, or CSS.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses lower case letters for all ASCII letters.
For non-ASCII letters—such as Greek, Cyrillic, or non-ASCII Latin letters—<a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> respects case sensitivity as it is called for.
</p>
<div id="element-names" class="section">
<h4><span class="secno">6.3.1 </span>Element Names</h4>
<p><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses the correct case for element names.</p>
<ul>
<li><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses lowercase letters for all HTML element names.</li>
<li><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses lowercase letters for all MathML element names.</li>
<li><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses lowercase letters for all SVG element names except the following,
for which <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> uses mixed case:
<ul>
<li><code>altGlyph</code></li>
<li><code>altGlyphDef</code></li>
<li><code>altGlyphItem</code></li>
<li><code>animateColor</code></li>
<li><code>animateMotion</code></li>
<li><code>animateTransform</code></li>
<li><code>clipPath</code></li>
<li><code>feBlend</code></li>
<li><code>feColorMatrix</code></li>
<li><code>feComponentTransfer</code></li>
<li><code>feComposite</code></li>
<li><code>feConvolveMatrix</code></li>
<li><code>feDiffuseLighting</code></li>
<li><code>feDisplacementMap</code></li>
<li><code>feDistantLight</code></li>
<li><code>feFlood</code></li>
<li><code>feFuncA</code></li>
<li><code>feFuncB</code></li>
<li><code>feFuncG</code></li>
<li><code>feFuncR</code></li>
<li><code>feGaussianBlur</code></li>
<li><code>feImage</code></li>
<li><code>feMerge</code></li>
<li><code>feMergeNode</code></li>
<li><code>feMorphology</code></li>
<li><code>feOffset</code></li>
<li><code>fePointLight</code></li>
<li><code>feSpecularLighting</code></li>
<li><code>feSpotLight</code></li>
<li><code>feTile</code></li>
<li><code>feTurbulence</code></li>
<li><code>foreignObject</code></li>
<li><code>glyphRef</code></li>
<li><code>linearGradient</code></li>
<li><code>radialGradient</code></li>
<li><code>textPath</code></li>
</ul>
</li>
</ul>
<!--End section: Element Names-->
</div>
<div id="attribute-names" class="section">
<h4><span class="secno">6.3.2 </span>Attribute Names</h4>
<p><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses the correct case for attribute names.</p>
<ul>
<li><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses lowercase letters in attribute names for all HTML elements.</li>
<li><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses lowercase letters in attribute names for all MathML elements except the lowercase <code>definitionurl</code>,
which <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> changes to the mixed case <code>definitionURL</code>.</li>
<li><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses lowercase letters in attribute names for all SVG elements except the following,
for which <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> uses mixed case:
<ul>
<li><code>attributeName</code></li>
<li><code>attributeType</code></li>
<li><code>baseFrequency</code></li>
<li><code>baseProfile</code></li>
<li><code>calcMode</code></li>
<li><code>clipPathUnits</code></li>
<li><code>contentScriptType</code></li>
<li><code>contentStyleType</code></li>
<li><code>diffuseConstant</code></li>
<li><code>edgeMode</code></li>
<li><code>externalResourcesRequired</code></li>
<li><code>filterRes</code></li>
<li><code>filterUnits</code></li>
<li><code>glyphRef</code></li>
<li><code>gradientTransform</code></li>
<li><code>gradientUnits</code></li>
<li><code>kernelMatrix</code></li>
<li><code>kernelUnitLength</code></li>
<li><code>keyPoints</code></li>
<li><code>keySplines</code></li>
<li><code>keyTimes</code></li>
<li><code>lengthAdjust</code></li>
<li><code>limitingConeAngle</code></li>
<li><code>markerHeight</code></li>
<li><code>markerUnits</code></li>
<li><code>markerWidth</code></li>
<li><code>maskContentUnits</code></li>
<li><code>maskUnits</code></li>
<li><code>numOctaves</code></li>
<li><code>pathLength</code></li>
<li><code>patternContentUnits</code></li>
<li><code>patternTransform</code></li>
<li><code>patternUnits</code></li>
<li><code>pointsAtX</code></li>
<li><code>pointsAtY</code></li>
<li><code>pointsAtZ</code></li>
<li><code>preserveAlpha</code></li>
<li><code>preserveAspectRatio</code></li>
<li><code>primitiveUnits</code></li>
<li><code>refX</code></li>
<li><code>refY</code></li>
<li><code>repeatCount</code></li>
<li><code>repeatDur</code></li>
<li><code>requiredExtensions</code></li>
<li><code>requiredFeatures</code></li>
<li><code>specularConstant</code></li>
<li><code>specularExponent</code></li>
<li><code>spreadMethod</code></li>
<li><code>startOffset</code></li>
<li><code>stdDeviation</code></li>
<li><code>stitchTiles</code></li>
<li><code>surfaceScale</code></li>
<li><code>systemLanguage</code></li>
<li><code>tableValues</code></li>
<li><code>targetX</code></li>
<li><code>targetY</code></li>
<li><code>textLength</code></li>
<li><code>viewBox</code></li>
<li><code>viewTarget</code></li>
<li><code>xChannelSelector</code></li>
<li><code>yChannelSelector</code></li>
<li><code>zoomAndPan</code></li>
</ul>
</li>
</ul>
<!--End section: Attribute Names-->
</div>
<div id="attribute-values" class="section">
<h4><span class="secno">6.3.3 </span>Attribute Values</h4>
<p>
For characters in attribute values, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> maintains case consistency between markup, DOM APIs, and CSS
when these attributes are used on HTML elements.
</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> maintains case consistency for values on the following attributes, which occur on
MIME types, language tags, charsets, booleans, media queries, and keywords.
Though not required, an easy way to maintain case-consistency is to use only lower case values for these attributes.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> maintains case consistency for these values
because, for the purpose of selector matching, attribute values in XML are all treated case sensitively;
however, HTML treats the values of these attributes as case insensitive
(See <a href="http://dev.w3.org/html5/spec/links.html#selectors">4.14.1 Case-sensitivity</a>, in the HTML5 specification). [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>]
</p>
<ul>
<li><code>accept</code></li>
<li><code>accept-charset</code></li>
<li><code>charset</code></li>
<li><code>checked</code></li>
<li><code>defer</code></li>
<li><code>dir</code></li>
<li><code>direction</code></li>
<li><code>disabled</code></li>
<li><code>enctype</code></li>
<li><code>hreflang</code></li>
<li><code>http-equiv</code></li>
<li><code>lang</code></li>
<li><code>media</code></li>
<li><code>method</code></li>
<li><code>multiple</code></li>
<li><code>readonly</code></li>
<li><code>rel</code> (for values that do not contain a colon)</li>
<li><code>scope</code></li>
<li><code>selected</code></li>
<li><code>shape</code></li>
<li><code>target</code> (keywords only; browsing context names are case-sensitive)</li>
<li><code>type</code> (on <code>a</code>, <code>link</code>, <code>object</code>, <code>script</code>, or <code>style</code> elements)</li>
<li><code>type</code> (on input)</li>
</ul>
<p>
Note that other specifications, such as RDFa, may place additional restrictions on the allowed values of certain attributes.
</p>
<!--End section: Attribute Values-->
</div>
<!--End section: Case-Sensitivity-->
</div>
<div id="empty-elements" class="section">
<h3><span class="secno">6.4 </span>Void Elements</h3>
<p><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses only the elements in the following list as void elements.</p>
<ul>
<li><code>area</code></li>
<li><code>base</code></li>
<li><code>br</code></li>
<li><code>col</code></li>
<li><code>command</code></li>
<li><code>embed</code></li>
<li><code>hr</code></li>
<li><code>img</code></li>
<li><code>input</code></li>
<li><code>keygen</code></li>
<li><code>link</code></li>
<li><code>meta</code></li>
<li><code>param</code></li>
<li><code>source</code></li>
</ul>
<p><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses the minimized tag syntax for void elements, e.g. <code><br/></code>,
rather than the alternative syntax <code><br></br></code>.
</p>
<p>
Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph)
<a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> does not use the minimized form (e.g. the document uses <code><p></p></code> and not <code><p /></code>).
</p>
<p>Note that MathML and SVG elements may be either self-closing or contain content.</p>
<!--End section: void Elements-->
</div>
<div id="elements-with-special-considerations" class="section">
<h3><span class="secno">6.5 </span>Elements with Special Considerations</h3>
<p>The following elements or their considerations require exceptions to the general rules for <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.</p>
<div id="http-headers-and-http-equiv" class="section">
<h4><span class="secno">6.5.1 </span>HTTP Headers and http-equiv Declarations</h4>
<div id="content-language" class="section">
<h5><span class="secno">6.5.1.1 </span>Content-Language</h5>
<!-- TODO per bug 12279 XXX -->
<p>
The HTTP Content-Language: header warrants special discussion in <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
</p>
<pre class="example">HTTP header: <code>Content-language: ru</code></pre>
<p>
Whenever there is an HTTP Content-Language: header (whose value is no more and no less than exactly one language tag),
<a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> declares both the <code>lang</code> and the <code>xml:lang</code> attributes on the root element.
For more information, see <a href="#language-attributes">Language Attributes</a>.
</p>
<p class="note">
As a general practice and for the sake of expediency and simplicity, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> may always include
both the <code>xml:lang</code> as well as the <code>lang</code> attributes on the root element.
</p>
<!-- End section: Content-Language -->
</div>
<div id="content-type" class="section">
<h5><span class="secno">6.5.1.2 </span>Content-Type</h5>
<p>
The <code>HTTP Content-Type:</code> header has no extra rules or restrictions,
whereas <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> does not use the <code>http-equiv="Content-Type"</code> declaration on the <code>meta</code> element.
For more specific information about using the <code>HTTP Content-Type:</code> header, see <a href="#character-encoding">Specifying a Document's Character Encoding</a>.
</p>
<!-- End section: Content-Type -->
</div>
<!-- End section: HTTP Headers and http-equiv Declarations -->
</div>
<div id="newlines-in-textarea-and-pre" class="section">
<h4><span class="secno">6.5.2 </span>Newlines in <code>textarea</code> and <code>pre</code> Elements</h4>
When <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> uses either a <code>textarea</code> or <code>pre</code> element,
the text within the element does not begin with a <a href="http://dev.w3.org/html5/spec/syntax.html#syntax-newlines">newline</a>.
<!--End section: White Space in textarea and pre Elements-->
</div>
<!--End section: Elements with Special Considerations-->
</div>
<!--End section: Elements-->
</div>
<div id="attributes" class="section">
<!--OddPage--><h2><span class="secno">7. </span>Attributes</h2>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> surrounds all attribute values with quotation marks.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> surrounds attribute values by either single quotation marks or by double quotation marks.
</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not use newline characters within an attribute.
</p>
<p>
Within an attribute's value, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> represents tabs, line feeds, and carriage returns
as numeric character references rather than by using literal characters.
For example, within an attribute's value, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> uses <code>&#x9;</code> for a tab
rather than the literal character <code>'\t'</code>.
This is because of attribute-value normalization in XML [<cite><a href="#bib-XML10" rel="biblioentry" class="bibref">XML10</a></cite>].
The following example uses numeric character references (escaped
characters) for the line feed, tab, and less-than characters within a <code>srcdoc</code> attribute.
</p>
<pre class="example"><iframe srcdoc="&lt;p>Hello &#x0A; &#x09; world!&lt;/p>" src="demo_iframe_srcdoc.htm"></iframe></pre>
<p class="note">
Because of attribute-value normalization in XML [<cite><a href="#bib-XML10" rel="biblioentry" class="bibref">XML10</a></cite>], <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>
does not use newline characters within an attribute.
Practically speaking, for source code with newlines within attributes,
DOMs generated via XML and HTML will be different;
however, whitespace differences have no behavioral impact on the page
unless explicitly examined by JavaScript, rendering the differences of
small consequence.
Note that newlines are overtly not allowed in the <code>title</code> attribute or in any attribute containing a URI.
</p>
<p>
See also <a href="#attribute-values">Attribute Values</a>.
</p>
<div id="disallowed-attributes" class="section">
<h3><span class="secno">7.1 </span>Disallowed Attributes</h3>
<p>The following attributes are not allowed in <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
These attributes have effects in documents parsed as XML but do not have effects in documents parsed as text/html.
The HTML5 spec therefore defines them as invalid in text/html documents. [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>]
</p>
<ul>
<li><code>xml:space</code></li>
<li><code>xml:base</code></li>
</ul>
<p> Note that the <code>xml:space</code> and <code>xml:base</code> attributes are allowed on SVG and MathML elements.</p>
<!--End section: Disallowed Attributes-->
</div>
<div id="language-attributes" class="section">
<h3><span class="secno">7.2 </span>Language Attributes</h3>
<p>
When specifying the language mapping of an element, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> uses both the <code>lang</code> and <code>xml:lang</code> attributes.
Neither attribute is to be used without the other, and <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> maintains identical values for both <code>lang</code> and <code>xml:lang</code>.</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses the language attributes in the <code>html</code>
element to set the default language for the document overtly.
Although HTML5 sets the language of the root element via a fallback
language mechanism, this mechanism is not required to work in XML.
</p>
<p class="note">
HTML5 activates the fallback language mechanism whenever the root element lacks language attributes.
For the mechanism to actually set a fallback language, however, it has to locate either an <code>http-equiv="Content-Language"</code> declaration on the <code>meta</code> element
or an <code>HTTP Content-Language:</code> header, either of whose content value is no more and no less than exactly one language tag.
Note that although the mechanism can locate either the meta element or the header, the meta element is considered first.
For more information about determining language in HTML5, see the <a href="http://www.w3.org/TR/html5/elements#language">language determination rules</a>. [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>].
</p>
<!--End section: Language Attributes-->
</div>
<div id="attributes-with-special-considerations" class="section">
<h3><span class="secno">7.3 </span>Attributes with Special Considerations</h3>
<p>
The following attributes or their considerations require exceptions to the general rules for <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
</p>
<div id="id-attribute" class="section">
<h4><span class="secno">7.3.1 </span>The <code>id</code> Attribute</h4>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not contain any space characters within the value of an <code>id</code> attribute.
This is because values for the <code>id</code> attribute <a href="http://dev.w3.org/html5/spec/elements.html#the-id-attribute">may not contain space characters</a> in HTML5. [<cite><a href="#bib-HTML5" rel="biblioentry" class="bibref">HTML5</a></cite>]
</p>
<!-- End section: The id Attribute -->
</div>
<!-- End section: Attributes with Special Considerations -->
</div>
<!--End section: Attributes-->
</div>
<div id="named-entity-references" class="section">
<!--OddPage--><h2><span class="secno">8. </span>Named Entity References</h2>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses only the following named entity references:</p>
<ul>
<li><code>amp</code></li>
<li><code>lt</code></li>
<li><code>gt</code></li>
<li><code>apos</code></li>
<li><code>quot</code></li>
</ul>
<p>
For entities beyond the previous list, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> uses character references.
For example, <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> uses <code>&#xA0;</code> instead of <code>&nbsp;</code>.
Note that <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> may use decimal values for escape characters (such as &#160; in the previous example);
however, the <a href="http://www.w3.org/TR/2005/REC-charmod-20050215/#C048">Character Model for the World Wide Web</a> recommends
that content <em title="should" class="rfc2119">should</em> use the hexadecimal form of character escapes rather than the decimal form when both are available. [<cite><a href="#bib-CHARMOD" rel="biblioentry" class="bibref">CHARMOD</a></cite>]
</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> always uses character references for the less than sign (<code><</code>) and ampersand (<code>&</code>) when they are used as characters,
except when those characters appear inside a CDATA section.
</p>
<!--End section: Named Entity References-->
</div>
<div id="script-and-style" class="section">
<!--OddPage--><h2><span class="secno">9. </span>Script and Style</h2>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> includes script and style commands by linking to external files rather than including them in-line.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not link to an external stylesheet by using the xml-stylesheet processing instruction.
See also <a href="#PI-and-xml">Processing Instructions and the XML Declaration</a>.
</p>
<p>The following examples show how <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> includes external script and style, respectively:</p>
<pre class="example"><script src="external.js"></script></pre>
<pre class="example"><link rel="stylesheet" href="external.css"/></pre>
<p>Although <code>document.write()</code> and <code>document.writeln()</code> are valid in an HTML document, neither function may be used in XHTML.
Therefore, neither is used in <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
Instead, use the <code>innerHTML</code> property for both HTML and XHTML.
Note that the <code>innerHTML</code> property takes a string.
XML parsers parse the string as XML in XHTML.
HTML parsers parse the string as HTML in HTML.
Because of the difference in parsing, if you send the parser content that does not follow the rules for <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>
the results will differ for a DOM create with an XML parser and one created with an HTML parser.
</p>
<div id="external-script-and-style" class="section">
<h3><span class="secno">9.1 </span>External Script and Style</h3>
<p><a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses external scripts if that document's script or style sheet uses <code><</code> or <code>&</code> or <code>]]></code> or <code>--</code>.
Note that XML parsers are permitted to silently remove the
contents of comments;
therefore, the historical practice of hiding scripts and style
sheets within comments to make the documents backward compatible is
likely to not work as expected in XML-based user agents.
</p>
<!--End section: External Script and Style-->
</div>
<div id="in-line-script-and-style" class="section">
<h3><span class="secno">9.2 </span>In-line Script and Style</h3>
<p>
When <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> must use script or style commands within its source code, it uses safe content.
</p>
<p>
Safe content is content that does not contain a <code><</code> or <code>&</code> character.
The following example is safe because it does not contain problematic characters within the <code>script</code> tag.
</p>
<pre class="example"><script>document.body.appendChild(document.createElement("div"));</script></pre>
<!--End section: In-line Script and Style-->
</div>
<!--End section: Script and Style-->
</div>
<div id="comments" class="section">
<!--OddPage--><h2><span class="secno">10. </span>Comments in Polyglot Markup</h2>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> does not begin a comment with either "<code>></code>" or "<code>-></code>".
</p>
<!--End section: Comments-->
</div>
<div id="foreign-content" class="section">
<!--OddPage--><h2><span class="secno">11. </span>Exceptions from the Foreign Content Parsing Rules</h2>
<p>
<!-- TODO: Need to call out exceptions from the foreign content parsing rules (e.g. <foreignContent> -->
</p>
<!--End section: Exceptions from the Foreign Content Parsing Rules-->
</div>
<div id="example-document" class="section">
<!--OddPage--><h2><span class="secno">12. </span>Example Document</h2>
<p>
The following example code acts as <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> and validates as either XHTML or as HTML. You can view the page live
at <a href="http://dev.w3.org/html5/html-xhtml-author-guide/SamplePage.html">http://dev.w3.org/html5/html-xhtml-author-guide/SamplePage.html</a>.
</p>
<pre class="example"><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>A Sample Page Using Polglot Markup</title>
<!-- The link element is self-closing as described in <a href="#empty-elements">Section 6.4 Void Elements</a> -->
<!-- Style commands are included by linking to an external file rather than including them in-line,
as described in <a href="#script-and-style">Section 9. Script and Style</a> -->
<link type="text/css" rel="stylesheet" href="Sample.css"/>
</head>
<body>
<h1>Sample Page Using Polyglot Markup</h1>
<p>
The source code for <a href="http://dev.w3.org/html5/html-xhtml-author-guide/SamplePage.html">this document</a> uses <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>,
a document that is a stream of bytes that parses into identical document trees
(with the exception of the xmlns attribute on the root element) when processed as HTML and when processed as XML.
The source code for <a href="http://dev.w3.org/html5/html-xhtml-author-guide/SamplePage.html">this document</a> also contains additional comments about the use of
<a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a>.
</p>
<h2>Foreign Elements</h2>
<p>
The following shapes use SVG elements.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> introduces undeclared (native) default namespaces
for the the root SVG element (<svg>) and respects the mixed-case element names and values
when appropriate, as described in sections <a href="#element-level-namespaces">5.1 Element-Level Namespaces</a>,
<a href="#element-names">6.3.1 Element Names</a>, and <a href="#attribute-values">6.3.3 Attribute Values</a>.
</p>
<!-- <a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> declares the xlink: namespace on the <svg> element to maintain XML-compatibility -->
<svg width="350" height="250" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<title>Three SVG shapes</title>
<desc>
This SVG image contains an ellipse filled with a gradient that goes from white to blue as it moves outward from the center.
A yellow rectangle with a black border overlaps the ellipse in the upper-left quadrant,
and a red spiral on a white background overlaps the ellipse in the bottom-right quadrant.
The red spiral is also a link to the example code for that SVG shape.
</desc>
<defs>
<!-- Note that "radialGradient" and "myGradient" respect mixed-case values. -->
<radialGradient id="myGradient" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(200,200,200); stop-opacity:0"/>
<stop offset="100%" style="stop-color:rgb(0,0,255); stop-opacity:1"/>
</radialGradient>
</defs>
<ellipse cx="50%" cy="50%" rx="50%" ry="42%" style="fill:url(#myGradient)"/>
<rect x="0" y="0" width="100" height="100" style="fill: yellow; stroke: black;"/>
<a xlink:href="http://www.w3schools.com/svg/tryit.asp?filename=path2&type=svg">
<!-- Note that the following attribute contains no newlines. -->
<path transform="translate(60, -175)" d="M153 334 C153 334 151 334 151 334 C151 339 153 344 156 344 C164 344 171 339 171 334 C171 322 164 314 156 314 C142 314 131 322 131 334 C131 350 142 364 156 364 C175 364 191 350 191 334 C191 311 175 294 156 294 C131 294 111 311 111 334 C111 361 131 384 156 384 C186 384 211 361 211 334 C211 300 186 274 156 274" style="fill:white;stroke:red;stroke-width:2"/>
</a>
</g>
</svg>
<h2>Void Elements</h2>
<!-- Given an empty instance of an element whose content model is not EMPTY (in this case, an empty paragraph)
<a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> does not use the minimized form, as described in <a href="#empty-elements">Section 6.4 Void Elements</a> -->
<p></p>
<p>
There is an empty <p> element before this paragraph.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses <p></p> and not <p />.
</p>
<p>
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> treats certain elements as self-closing,
void elements, such as the following <img> element.
</p>
<img height="48" width="72" alt="W3C" src="http://www.w3.org/Icons/w3c_home"/>
<p>
For more information, see <a href="#empty-elements">Section 6.4 Void Elements</a>.
</p>
<h2>Required Elements</h2>
<p>
The following table uses the required <tbody> element, as described in
<a href="#required-elements">Section 6.1 Required Elements</a>.
</p>
<table>
<tbody>
<tr>
<th>Column One</th>
<th>Column Two</th>
</tr>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
<tr>
<td>Row 3, Column 1</td>
<td>Row 3, Column 2</td>
</tr>
</tbody>
</table>
<p>
The following table uses the required <colgroup> element, as described in
<a href="#required-elements">Section 6.1 Required Elements</a>.
</p>
<table>
<colgroup>
<col style="background-color:silver"/>
<col style="background-color:gray"/>
<col style="background-color:yellow"/>
</colgroup>
<tbody>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
<tr>
<td>1234567</td>
<td>Intermediate Polyglot</td>
<td>$49</td>
</tr>
</tbody>
</table>
<h2>Named Entity References</h2>
<p>
This paragraph uses the string "&amp;" for ampersands ("&") and uses the string "&#xA0;"
for a nonbreaking space between the words "polyglot markup," as described in
<a href="#named-entity-references">Section 8. Named Entity References</a>.
</p>
</body>
</html> </pre>
<!--End section: Example Document-->
</div>
<!-- Appendix -->
<div id="acknowledgements" class="appendix section">
<h2><span class="secno">A. </span>Acknowledgements</h2>
<p>
Many thanks to Robin Berjon, David Carlisle, Daniel Glazman, Richard Ishida, Tony Ross,
Sam Ruby, Jonas Sicking, Leif Halvard Silli, Henri Sivonen, Manu Sporny, and Philip Taylor.
Special thanks to the W3C TAG and the W3C Internationalization (i18n) Core Working Group.
</p>
</div>
<div class="appendix section" id="references">
<h2><span class="secno">B. </span>References</h2>
<div class="section" id="normative-references">
<h3><span class="secno">B.1 </span>Normative references</h3>
<dl class="bibliography">
<dt id="bib-CHARMOD">[CHARMOD]</dt>
<dd>Martin J. Dürst; et al. <a href="http://www.w3.org/TR/2005/REC-charmod-20050215"><cite>Character Model for the World Wide Web 1.0: Fundamentals.</cite></a>
15 February 2005. W3C Recommendation. URL: <a href="http://www.w3.org/TR/2005/REC-charmod-20050215">http://www.w3.org/TR/2005/REC-charmod-20050215</a>
</dd>
<dt id="bib-HTML5">[HTML5]</dt>
<dd>Ian Hickson; David Hyatt. <a href="http://www.w3.org/TR/html5"><cite>HTML 5.</cite></a> 4 March 2010. W3C Working Draft. (Work in progress.)
URL: <a href="http://www.w3.org/TR/html5">http://www.w3.org/TR/html5</a>
</dd>
<dt id="bib-HTTP11">[HTTP11]</dt>
<dd>R. Fielding; et al. <a href="http://www.ietf.org/rfc/rfc2616.txt"><cite>Hypertext Transfer Protocol - HTTP/1.1.</cite></a> June 1999. Internet RFC 2616. URL:
<a href="http://www.ietf.org/rfc/rfc2616.txt">http://www.ietf.org/rfc/rfc2616.txt</a>
</dd>
<dt id="bib-RFC2854">[RFC2854]</dt>
<dd>D. Connolly; L. Masinter. <a href="http://www.rfc-editor.org/rfc/rfc2854.txt"><cite>The 'text/html' Media Type.</cite></a> June 2000. Internet RFC 2854. URL:
<a href="http://www.rfc-editor.org/rfc/rfc2854.txt">http://www.rfc-editor.org/rfc/rfc2854.txt</a>
</dd>
<dt id="bib-XML-MT">[XML-MT]</dt>
<dd>M. Murata, S. St.Laurent, D. Kohn. <a href="http://www.ietf.org/rfc/rfc3023.txt"><cite>XML Media Types</cite></a>. IETF RFC 3023. URI:
<a href="http://www.ietf.org/rfc/rfc3023.txt"> http://www.ietf.org/rfc/rfc3023.txt</a>.
</dd>
<dt id="bib-XML10">[XML10]</dt><dd>C. M. Sperberg-McQueen; et al. <a href="http://www.w3.org/TR/2008/REC-xml-20081126/"><cite>Extensible Markup Language (XML) 1.0 (Fifth Edition).</cite></a>
26 November 2008. W3C Recommendation. URL: <a href="http://www.w3.org/TR/2008/REC-xml-20081126/">http://www.w3.org/TR/2008/REC-xml-20081126/</a>
</dd>
</dl>
</div>
<div class="section" id="informative-references">
<h3><span class="secno">B.2 </span>Informative references</h3>
<p>
No informative references.
</p>
</div>
</div>
<!-- End Appendix -->
</body>
</html>