Another abandoned server code base... this is kind of an ancestor of taskrambler.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1174 lines
64 KiB

<!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> &#xA9; 2011
<a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>&#xAE;</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&#x2014;normally lower case but occasionally camel case&#x2014;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&#x2014;such as
quick testing or even hand-authoring&#x2014;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>&lt;meta charset="UTF-8"/&gt;</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>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;</code></li>
<li><code>&lt;math xmlns="http://www.w3.org/1998/Math/MathML"&gt;</code></li>
<li><code>&lt;svg xmlns="http://www.w3.org/2000/svg"&gt;</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">&lt;!DOCTYPE html&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""&gt;
&lt;head&gt;
&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</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">&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;...</pre>
Incorrect:
<pre class="example">&lt;table&gt;
&lt;tr&gt;...</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">&lt;table&gt;
&lt;colgroup&gt;
&lt;col&gt;...</pre>
Incorrect:
<pre class="example">&lt;table&gt;
&lt;col&gt;...</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&#x2014;such as Greek, Cyrillic, or non-ASCII Latin letters&#x2014;<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>&lt;br/&gt;</code>,
rather than the alternative syntax <code>&lt;br&gt;&lt;/br&gt;</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>&lt;p&gt;&lt;/p&gt;</code> and not <code>&lt;p /&gt;</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>&amp;#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">&lt;iframe srcdoc="&amp;lt;p&gt;Hello &amp;#x0A; &amp;#x09; world!&amp;lt;/p&gt;" src="demo_iframe_srcdoc.htm"&gt;&lt;/iframe&gt;</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>&amp;#xA0;</code> instead of <code>&amp;nbsp;</code>.
Note that <a class="internalDFN" href="#dfn-polyglot-markup">polyglot markup</a> may use decimal values for escape characters (such as &amp;#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>&lt;</code>) and ampersand (<code>&amp;</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">&lt;script src="external.js"&gt;&lt;/script&gt;</pre>
<pre class="example">&lt;link rel="stylesheet" href="external.css"/&gt;</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>&lt;</code> or <code>&amp;</code> or <code>]]&gt;</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>&lt;</code> or <code>&amp;</code> character.
The following example is safe because it does not contain problematic characters within the <code>script</code> tag.
</p>
<pre class="example">&lt;script&gt;document.body.appendChild(document.createElement("div"));&lt;/script&gt;</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>&gt;</code>" or "<code>-&gt;</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">&lt;!DOCTYPE html&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"&gt;
&lt;head&gt;
&lt;title&gt;A Sample Page Using Polglot Markup&lt;/title&gt;
&lt;!-- The link element is self-closing as described in <a href="#empty-elements">Section 6.4 Void Elements</a> --&gt;
&lt;!-- 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> --&gt;
&lt;link type="text/css" rel="stylesheet" href="Sample.css"/&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Sample Page Using Polyglot Markup&lt;/h1&gt;
&lt;p&gt;
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>.
&lt;/p&gt;
&lt;h2&gt;Foreign Elements&lt;/h2&gt;
&lt;p&gt;
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 (&lt;svg&gt;) 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>.
&lt;/p&gt;
&lt;!-- <a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> declares the xlink: namespace on the &lt;svg&gt; element to maintain XML-compatibility --&gt;
&lt;svg width="350" height="250" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
&lt;g&gt;
&lt;title&gt;Three SVG shapes&lt;/title&gt;
&lt;desc&gt;
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.
&lt;/desc&gt;
&lt;defs&gt;
&lt;!-- Note that "radialGradient" and "myGradient" respect mixed-case values. --&gt;
&lt;radialGradient id="myGradient" cx="50%" cy="50%" r="50%" fx="50%" fy="50%"&gt;
&lt;stop offset="0%" style="stop-color:rgb(200,200,200); stop-opacity:0"/&gt;
&lt;stop offset="100%" style="stop-color:rgb(0,0,255); stop-opacity:1"/&gt;
&lt;/radialGradient&gt;
&lt;/defs&gt;
&lt;ellipse cx="50%" cy="50%" rx="50%" ry="42%" style="fill:url(#myGradient)"/&gt;
&lt;rect x="0" y="0" width="100" height="100" style="fill: yellow; stroke: black;"/&gt;
&lt;a xlink:href="http://www.w3schools.com/svg/tryit.asp?filename=path2&amp;type=svg"&gt;
&lt;!-- Note that the following attribute contains no newlines. --&gt;
&lt;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"/&gt;
&lt;/a&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;h2&gt;Void Elements&lt;/h2&gt;
&lt;!-- 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> --&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;
There is an empty &lt;p&gt; element before this paragraph.
<a class="internalDFN" href="#dfn-polyglot-markup" title="polyglot markup">Polyglot markup</a> uses &lt;p&gt;&lt;/p&gt; and not &lt;p /&gt;.
&lt;/p&gt;
&lt;p&gt;
<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 &lt;img&gt; element.
&lt;/p&gt;
&lt;img height="48" width="72" alt="W3C" src="http://www.w3.org/Icons/w3c_home"/&gt;
&lt;p&gt;
For more information, see <a href="#empty-elements">Section 6.4 Void Elements</a>.
&lt;/p&gt;
&lt;h2&gt;Required Elements&lt;/h2&gt;
&lt;p&gt;
The following table uses the required &lt;tbody&gt; element, as described in
<a href="#required-elements">Section 6.1 Required Elements</a>.
&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Column One&lt;/th&gt;
&lt;th&gt;Column Two&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Row 1, Column 1&lt;/td&gt;
&lt;td&gt;Row 1, Column 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Row 2, Column 1&lt;/td&gt;
&lt;td&gt;Row 2, Column 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Row 3, Column 1&lt;/td&gt;
&lt;td&gt;Row 3, Column 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The following table uses the required &lt;colgroup&gt; element, as described in
<a href="#required-elements">Section 6.1 Required Elements</a>.
&lt;/p&gt;
&lt;table&gt;
&lt;colgroup&gt;
&lt;col style="background-color:silver"/&gt;
&lt;col style="background-color:gray"/&gt;
&lt;col style="background-color:yellow"/&gt;
&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;ISBN&lt;/th&gt;
&lt;th&gt;Title&lt;/th&gt;
&lt;th&gt;Price&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3476896&lt;/td&gt;
&lt;td&gt;My first HTML&lt;/td&gt;
&lt;td&gt;$53&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1234567&lt;/td&gt;
&lt;td&gt;Intermediate Polyglot&lt;/td&gt;
&lt;td&gt;$49&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Named Entity References&lt;/h2&gt;
&lt;p&gt;
This paragraph uses the string "&amp;amp;" for ampersands ("&amp;") and uses the string "&amp;#xA0;"
for a nonbreaking space between the words "polyglot&nbsp;markup," as described in
<a href="#named-entity-references">Section 8. Named Entity References</a>.
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt; </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>