W3C home > Mailing lists > Public > public-html-commits@w3.org > April 2010

html5/html-xhtml-author-guide html-xhtml-authoring-guide-rendered.html,NONE,1.1

From: Eliot Graff via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 21 Apr 2010 22:39:56 +0000
To: public-html-commits@w3.org
Message-Id: <E1O4iaK-0000lD-CN@lionel-hutz.w3.org>
Update of /sources/public/html5/html-xhtml-author-guide
In directory hutz:/tmp/cvs-serv2909

Added Files:
	html-xhtml-authoring-guide-rendered.html 
Log Message:
Version of spec for browsers that do not run ReSpec scripts

--- NEW FILE: html-xhtml-authoring-guide-rendered.html ---
<!DOCTYPE HTML>
<html dir="ltr" lang="en"><head>

  
    <title>HTML/XHTML Compatibility Authoring Guidelines</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- 
      === NOTA BENE ===
      For the three scripts below, if your spec resides on dev.w3 you can check them
      out in the same tree and use relative links so that they'll work offline,
     -->
    
    
  <link charset="utf-8" type="text/css" rel="stylesheet" 
href="html-xhtml-authoring-guide-rendered_files/respec.css"><link 
charset="utf-8" type="text/css" rel="stylesheet" 
href="html-xhtml-authoring-guide-rendered_files/W3C-ED.css"></head><body
 style="display: inherit;"><div class="head"><p><a 
href="http://www.w3.org/"><img 
src="html-xhtml-authoring-guide-rendered_files/w3c_home.png" alt="W3C" 
width="72" height="48"></a></p><h1 class="title" id="title">HTML/XHTML 
Compatibility Authoring Guidelines</h1><h2 
id="w3c-editor-s-draft-21-april-2010"><acronym title="World Wide Web 
Consortium">W3C</acronym> Editor's Draft 21 April 2010</h2><dl><dt>This 
version:</dt><dd><a 
href="http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-authoring-guide.html">http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-authoring-guide.html</a></dd><dt>Latest
 published version:</dt><dd><a href="http://www.w3.org/TR/xxx-xxx/">http://www.w3.org/TR/xxx-xxx/</a></dd><dt>Latest
 editor's draft:</dt><dd><a 
href="http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-authoring-guide.html">http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-authoring-guide.html</a></dd><dt>Previous
 version:</dt><dd>none</dd><dt>Editor:</dt><dd>Eliot Graff, Microsoft 
Corporation</dd></dl><p class="copyright"><a 
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
 © 2010 <a href="http://www.w3.org/"><acronym title="World Wide Web 
Consortium"><acronym title="World Wide Web Consortium">W3C</acronym></acronym></a><sup>®</sup>
 (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts 
Institute of Technology"><acronym title="Massachusetts Institute of 
Technology">MIT</acronym></acronym></a>, <a href="http://www.ercim.eu/"><acronym
 title="European Research Consortium for Informatics and Mathematics"><acronym
 title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></acronym></a>,
 <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. <acronym
 title="World Wide Web Consortium">W3C</acronym> <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><hr></div>
    <div class="introductory section" id="abstract"><h2>Abstract</h2>
      <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. 
      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 these definitions, see [<a href="#bib-HTML5" 
rel="biblioentry" class="bibref">HTML5</a>] and [<a href="#bib-RFC2854" 
rel="biblioentry" class="bibref">RFC2854</a>] respectively.
      </p>
      <p><strong>Note:</strong>   If your browser does not render the 
fully formatted version of this document with images and color fonts, 
please see <a href=""></a>.</p>
    </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 <acronym title="World Wide Web Consortium">W3C</acronym>
 publications and the latest revision of this technical report can be 
found in the <a href="http://www.w3.org/TR/"><acronym title="World Wide 
Web Consortium">W3C</acronym> technical reports index</a> at 
http://www.w3.org/TR/.</em></p><p>This document was published by the <a 
href="http://www.w3.org/html/wg/"><acronym title="World Wide Web 
Consortium">W3C</acronym> HTML</a> as an Editor's Draft. If you wish to 
make comments regarding this document, please send them to <a 
href="mailto:public-html@w3.org">public-html@w3.org</a> (<a 
href="mailto:public-html-request@w3.org?subject=subscribe">subscribe</a>,
 <a href="http://lists.w3.org/Archives/Public/public-html/">archives</a>).
 All feedback is welcome.</p><p>Publication as a Editor's Draft does not
 imply endorsement by the <acronym title="World Wide Web Consortium">W3C</acronym>
 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>This document was 
produced by a group operating under the <a 
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 
2004 <acronym title="World Wide Web Consortium">W3C</acronym> Patent 
Policy</a>. <acronym title="World Wide Web Consortium">W3C</acronym> 
maintains a <a href="" 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 <acronym title="World Wide Web Consortium">W3C</acronym> 
Patent Policy</a>.</p></div><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="#processing-instructions-and-the-xml-declaration"><span
 class="secno">2. </span>Processing Instructions and the XML Declaration</a></li><li
 class="tocline"><a class="tocxref" href="#the-doctype"><span 
class="secno">3. </span>The DOCTYPE</a></li><li class="tocline"><a 
class="tocxref" href="#namespaces"><span class="secno">4. </span>Namespaces</a></li><li
 class="tocline"><a class="tocxref" href="#elements"><span class="secno">5.
 </span>Elements</a><ul class="toc"><li class="tocline"><a 
class="tocxref" href="#required-elements"><span class="secno">5.1 </span>Required
 Elements</a><ul class="toc"><li class="tocline"><a class="tocxref" 
href="#tables"><span class="secno">5.1.1 </span>Tables</a></li></ul></li><li
 class="tocline"><a class="tocxref" href="#case-sensitivity"><span 
class="secno">5.2 </span>Case-Sensitivity</a><ul class="toc"><li 
class="tocline"><a class="tocxref" href="#element-names"><span 
class="secno">5.2.1 </span>Element Names</a></li><li class="tocline"><a 
class="tocxref" href="#attribute-names"><span class="secno">5.2.2 </span>Attribute
 Names</a></li><li class="tocline"><a class="tocxref" 
href="#attribute-values"><span class="secno">5.2.3 </span>Attribute 
Values</a></li></ul></li><li class="tocline"><a class="tocxref" 
href="#empty-elements"><span class="secno">5.3 </span>Empty Elements</a></li></ul></li><li
 class="tocline"><a class="tocxref" href="#attributes"><span 
class="secno">6. </span>Attributes</a></li><li class="tocline"><a 
class="tocxref" href="#named-entity-references"><span class="secno">7. </span>Named
 Entity References</a></li><li class="tocline"><a class="tocxref" 
href="#script-and-style"><span class="secno">8. </span>Script and Style</a><ul
 class="toc"><li class="tocline"><a class="tocxref" 
href="#external-script-and-style"><span class="secno">8.1 </span>External
 Script and Style</a></li><li class="tocline"><a class="tocxref" 
href="#in-line-script-and-style"><span class="secno">8.2 </span>In-line 
Script and Style</a></li></ul></li><li class="tocline"><a 
class="tocxref" 
href="#exceptions-from-the-foreign-content-parsing-rules"><span 
class="secno">9. </span>Exceptions from the Foreign Content Parsing 
Rules</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>
    
    <div class="section" id="introduction">
      <!--OddPage--><h2><span class="secno">1. </span>Introduction</h2>
      <p>
        It is often valuable to be able to serve HTML5 documents that 
are also valid 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. 
These documents are served as text/html. 
		The language used to create documents that can be parsed by both HTML 
and XML parsers is called <dfn id="dfn-polyglot">polyglot</dfn>. 
		Polyglot is the overlap language of documents which are both HTML5 
documents and XML documents. 
 
        	<!-- <ul>
 			TODO: in this section:
        		<li>Offer "top-tier" summary of general guidelines to conform to polyglot language.</li>
        		<li>Link to more detailed analysis below.</li>
        	</ul>  -->
        
      </p>
    </div>
    
	<div class="section" 
id="processing-instructions-and-the-xml-declaration">
	<!--OddPage--><h2><span class="secno">2. </span>Processing Instructions
 and the XML Declaration</h2>
		<p>
			You <em title="must not" class="rfc2119">must not</em> use processing
 instructions in a polyglot document. You <em title="should" 
class="rfc2119">should</em> use the HTML <code>meta</code> tag to 
specify character and coding in the document. 
			If a polyglot document uses an encoding other than UTF8 or UTF16, you
 <em title="should" class="rfc2119">should</em> include the XML 
declaration; however, in this case you <em title="should" 
class="rfc2119">should</em> also include the HTML <code>meta</code> tag 
specifying the character set. 
			When you use both the XML declaration and the HTML <code>meta</code> 
tag, they <em title="must" class="rfc2119">must</em> specify the same 
character and coding.
		</p>
	</div>

	<div class="section" id="the-doctype">
	<!--OddPage--><h2><span class="secno">3. </span>The DOCTYPE</h2>
	<p>
		For a polyglot document, you <em title="must" class="rfc2119">must</em>
 use the <a href="http://dev.w3.org/html5/spec/syntax.html#the-doctype">HTML
 DOCTYPE</a>.
	</p>
	</div>    
    
    <div class="section" id="namespaces">
      <!--OddPage--><h2><span class="secno">4. </span>Namespaces</h2>
      <p>
        The following guidelines apply to namespaces used in polyglot 
documents.
      </p>
      <ul>
      	<li>
      		The <code>&lt;html&gt;</code> element <em title="must" 
class="rfc2119">must</em> have the namespace declaration <code>xmlns="http://www.w3.org/1999/xhtml"</code>.
      	</li>
      	<li>
      		All <code>&lt;math&gt;</code> elements <em title="must" 
class="rfc2119">must</em> have the namespace declaration <code>xmlns="http://www.w3.org/1998/Math/MathML"</code>.
      	</li>
      	<li>
      		All <code>&lt;svg&gt;</code> elements <em title="must" 
class="rfc2119">must</em> have the namespace declaration <code>xmlns="http://www.w3.org/2000/svg"</code>.
      	</li>
      	<li>
      		The xlink prefix <em title="must" class="rfc2119">must</em> be 
defined as <code>xmlns:xlink="http://www.w3.org/1999/xlink"</code> 
before using xlink:href. The prefix can be defined either:
      			<ul>
      				<li>
      					Once on the root <code>&lt;html&gt;</code> element.
      				</li>
      				<li>
      					Once on each <code>&lt;svg&gt;</code> element that contains 
one or more elements with xlink:href attributes.
      				</li>
      			</ul>
      	</li>
      	<li>
      		No other elements should have namespace declarations.
      	</li>
      </ul>
    </div>

    <div class="section" id="elements">
    <!--OddPage--><h2><span class="secno">5. </span>Elements</h2>
	    <div class="section" id="required-elements">
	    <h3><span class="secno">5.1 </span>Required Elements</h3>
	    	<p>
	    		Each document <em title="must" class="rfc2119">must</em> have a 
root <code>html</code> element. The root <code>html</code> element <em 
title="must" class="rfc2119">must</em> contain both a <code>head</code> 
and a <code>body</code> element.
	    		The <code>head</code> element <em title="must" class="rfc2119">must</em>
 contain a <code>title</code> element.

	    	</p>
	    	
	    	<div class="section" id="tables">
	    	<h4><span class="secno">5.1.1 </span>Tables</h4>
	    	<p>
	    		For a polyglot document, a table <em title="must" class="rfc2119">must</em>
 explicitly have a <code>tbody</code> element surrounding groups of <code>tr</code>
 elements. 
	    		HTML pasrsers insert the <code>tbody</code> element, but XML 
parsers do not, thus 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>
	    	
	    	</div>
	    </div>
	    
	    <div class="section" id="case-sensitivity">
	      <h3><span class="secno">5.2 </span>Case-Sensitivity</h3>
	      <p>
	        The following guidelines apply to markup, script, and CSS.
	      </p>
	
	        <div class="section" id="element-names">
	        <h4><span class="secno">5.2.1 </span>Element Names</h4>
	        	<p>You <em title="must" class="rfc2119">must</em> use the 
correct case for element names.</p>
				<ul>
					<li>
						Element names <em title="must" class="rfc2119">must</em> be 
lowercase for all HTML elements.
					</li>
					<li>
						Element names <em title="must" class="rfc2119">must</em> be 
lowercase for all MathML elements.
					</li>
					<li>
						Element names <em title="must" class="rfc2119">must</em> be 
lowercase for all SVG elements except the following, which <em 
title="must" class="rfc2119">must</em> be in 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>
	        </div>
	
			<div class="section" id="attribute-names">
			<h4><span class="secno">5.2.2 </span>Attribute Names</h4>
				<p>
					You <em title="must" class="rfc2119">must</em> use the correct case
 for attribute names.
				</p>
	        			<ul>
	        				<li>
	        					Attribute names <em title="must" class="rfc2119">must</em>
 be lowercase for all HTML elements.
	        				</li>
	        				<li>
	        					Attribute names <em title="must" class="rfc2119">must</em>
 be lowercase for all MathML elements except the following:
	        						<p>The lowercase <code>definitionurl</code> <em 
title="must" class="rfc2119">must</em> be changed to the mixed case <code>definitionURL</code>.</p>
	        				</li>
							<li>
	        					Attribute names <em title="must" class="rfc2119">must</em>
 be lowercase for all SVG elements except the following, which <em 
title="must" class="rfc2119">must</em> be in 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>
			</div>
	
			<div class="section" id="attribute-values">
			<h4><span class="secno">5.2.3 </span>Attribute Values</h4>
				<p>
					You <em title="must" class="rfc2119">must</em> specify attribute 
values as lowercase.
				</p>
			</div>
	    </div>
	
	
	    <div class="section" id="empty-elements">
	      <h3><span class="secno">5.3 </span>Empty Elements</h3>
	      <p>
	        You <em title="may" class="rfc2119">may</em> use only the 
elements in the following table as empty 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>
	      	You <em title="should" class="rfc2119">should</em> include a 
space before the trailing <code>/</code> and <code>&gt;</code> of empty 
elements, e.g. <code>&lt;br /&gt;</code>, <code>&lt;hr /&gt;</code> and <code>&lt;img
 src="karen.jpg" alt="Karen" /&gt;</code>. 
	      	Also, you <em title="should" class="rfc2119">should</em> use the
 minimized tag syntax for empty elements, e.g. <code>&lt;br /&gt;</code>.
 
	      	The alternative syntax <code>&lt;br&gt;&lt;/br&gt;</code> 
allowed by XML gives uncertain results in many existing user agents.
	      </p>
	      <p>
	      	Given an empty instance of an element whose content model is not
 EMPTY (for example, an empty title or paragraph) do not use the 
minimized form (e.g. use <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>
	    </div>
    </div>

	<div class="section" id="attributes">
	<!--OddPage--><h2><span class="secno">6. </span>Attributes</h2>
		<p>Avoid line breaks and multiple white space characters within 
attribute values. These are handled inconsistently by user agents.</p>
		<p>See also <a href="#attribute-values">Attribute Values</a>.</p>
	
	</div>

    <div class="section" id="named-entity-references">
      <!--OddPage--><h2><span class="secno">7. </span>Named Entity 
References</h2>
      <p>
        You <em title="should" class="rfc2119">should</em> use 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>
      	When you need entities beyond the previous list, use character 
references.
      </p>
      <p>
      	The named character reference <code>&amp;apos;</code> (the 
apostrophe, U+0027) was introduced in XML 1.0 but does not appear in 
HTML. 
      	Authors should therefore use <code>&amp;#39;</code> instead of <code>&amp;apos;</code>
 to work as expected in HTML user agents.
      </p>
    </div>


    <div class="section" id="script-and-style">
      <!--OddPage--><h2><span class="secno">8. </span>Script and Style</h2>
      <p>
        Script and style commands <em title="should" class="rfc2119">should</em>
 be included by linking to external files rather than including them 
in-line. 
      </p>
      <p>
      	Although you <em title="may" class="rfc2119">may</em> use <code>document.write()</code>
 and <code>document.writeln()</code> in an HTML document, you <em 
title="must not" class="rfc2119">must not</em> use either function in 
XHTML and therefore in a polyglot document.
      	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. 
      	Therefore, if you send the parser content that does not follow 
the rules for a polyglot document the results will differ for a DOM 
create with an XML parser and one created with an HTML parser.
      </p>
      <div class="section" id="external-script-and-style">
      <h3><span class="secno">8.1 </span>External Script and Style</h3>
      <p> 
        You <em title="must" class="rfc2119">must</em> use external 
scripts if your script uses <code>&lt;</code> or <code>&amp;</code> or <code>]]&gt;</code>
 or <code>--</code>. 
        You <em title="must" class="rfc2119">must</em> use external 
style sheets if your 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>
      </div>
      <div class="section" id="in-line-script-and-style">
      	<h3><span class="secno">8.2 </span>In-line Script and Style</h3>
      	<p>
      	If you must use script or style commands within your source code,
 either use safe content or wrap the command in a CDATA section. 
However, you <em title="should not" class="rfc2119">should not</em> use a
 <code>CDATA</code> section unless it is being used within foreign 
content.
      	</p><ul>
      		<li>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>&lt;script&gt;</code> tag.
				<pre class="example">&lt;script&gt;document.body.appendChild(document.createElement("div"));&lt;/script&gt;</pre>
      		</li>
      		<li>Wrap in-line script and style commands in a CDATA section</li>
				<p>
					Note that you cannot achieve same DOM in both XHTML and HTML by 
using in-line commands in a CDATA section. 
					However, this is not usally a problem unless the code has a 
dependency on the exact number of text nodes under a <code>&lt;script&gt;</code>
 or <code>&lt;style&gt;</code> element.
					The following examples show in-line script and style commands 
wrapped in a <code>CDATA</code> section.
      			</p>
      					<pre class="example">&lt;script&gt;
//&lt;![CDATA[
	(script goes here)
//]]&gt;
&lt;/script&gt;</pre>
      					<pre class="example">&lt;style&gt;
/*&lt;![CDATA[*/
	(styles go here)
/*]]&gt;*/
&lt;/style&gt;</pre>
				<p>
  					When using MathML or SVG, the parser follows the XML parsing 
rules. 
  					You <em title="must not" class="rfc2119">must not</em> rely on 
getting a CDATA instance from the DOM when using MathML or SVG, because 
the HTML parser does not create a CDATA instance in the DOM.
				</p>
      			
      	</ul>
      	
      </div>
    </div>



    <div class="section" 
id="exceptions-from-the-foreign-content-parsing-rules">
      <!--OddPage--><h2><span class="secno">9. </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>
    </div>
    
    
    <div id="acknowledgements" class="appendix section">
      <!--OddPage--><h2><span class="secno">A. </span>Acknowledgements</h2>
      <p>
        Many thanks to Tony Ross, Jonas Sicking, and Sam Ruby.
      </p>
    </div>
  <div class="appendix section" id="references"><!--OddPage--><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-HTML5">[HTML5]</dt><dd>Ian
 Hickson; David Hyatt. <a 
href="http://www.w3.org/TR/2010/WD-html5-20100304/"><cite>HTML 5.</cite></a>
 4 March 2010. W3C Working Draft. (Work in progress.) URL: <a 
href="http://www.w3.org/TR/2010/WD-html5-20100304/">http://www.w3.org/TR/2010/WD-html5-20100304/</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></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></body></html>
Received on Wednesday, 21 April 2010 22:39:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 21 April 2010 22:40:14 GMT