📄 xhtml1.xhtml
字号:
<ul><li>All whitespace surrounding block elements should be removed.</li><li>Comments are removed entirely and do not affect whitespace handling. Onewhitespace character on either side of a comment is treated as two whitespace characters.</li><li>Leading and trailing whitespace inside a block element must be removed.</li><li>Line feed characters within a block element must be converted into aspace (except when the 'xml:space' attribute is set to 'preserve').</li><li>A sequence of white space characters must be reduced to a single spacecharacter (except when the 'xml:space' attribute is set to 'preserve').</li><li>With regard to rendition,the User Agent should render the content in amanner appropriate to the language in which the content is written.In languages whose primary script is Latinate, the ASCII spacecharacter is typically used to encode both grammatical word boundaries andtypographic whitespace; in languages whose script is related to Nagari(e.g., Sanskrit, Thai, etc.), grammatical boundaries may be encoded usingthe ZW 'space' character, but will not typically be represented bytypographic whitespace in rendered output; languages using Arabiform scriptsmay encode typographic whitespace using a space character, but may also usethe ZW space character to delimit 'internal' grammatical boundaries (whatlook like words in Arabic to an English eye frequently encode several words,e.g. 'kitAbuhum' = 'kitAbu-hum' = 'book them' == their book); and languagesin the Chinese script tradition typically neither encode such delimiters noruse typographic whitespace in this way. </li></ul><p>Whitespace in attribute values is processed according to <ahref="#ref-xml">[XML]</a>.</p></li></ol><!--OddPage--><h1><a name="diffs" id="diffs">4. Differences with HTML4.0</a></h1><p>Due to the fact that XHTML is an XML application, certainpractices that were perfectly legal in SGML-based HTML 4.0 <ahref="#ref-html4">[HTML]</a> must be changed.</p><h2><a name="h-4.1" id="h-4.1">4.1 Documents must bewell-formed</a></h2><p><a href="#wellformed">Well-formedness</a> is a new conceptintroduced by <a href="#ref-xml">[XML]</a>. Essentially thismeans that all elements must either have closing tags or bewritten in a special form (as described below), and that all theelements must nest.</p><p>Although overlapping is illegal in SGML, it was widelytolerated in existing browsers.</p><div class="good"><p><strong><em>CORRECT: nested elements.</em></strong></p><p><p>here is an emphasized<em>paragraph</em>.</p></p></div><div class="bad"><p><strong><em>INCORRECT: overlapping elements</em></strong></p><p><p>here is an emphasized<em>paragraph.</p></em></p></div><h2><a name="h-4.2" id="h-4.2">4.2 Element and attributenames must be in lower case</a></h2><p>XHTML documents must use lower case for all HTML element andattribute names. This difference is necessary because XML iscase-sensitive e.g. <li> and <LI> are differenttags.</p><h2><a name="h-4.3" id="h-4.3">4.3 For non-empty elements,end tags are required</a></h2><p>In SGML-based HTML 4.0 certain elements were permitted to omitthe end tag; with the elements that followed implying closure.This omission is not permitted in XML-based XHTML. All elementsother than those declared in the DTD as <code>EMPTY</code> musthave an end tag.</p><div class="good"><p><strong><em>CORRECT: terminated elements</em></strong></p><p><p>here is a paragraph.</p><p>here isanother paragraph.</p></p></div><div class="bad"><p><strong><em>INCORRECT: unterminated elements</em></strong></p><p><p>here is a paragraph.<p>here is anotherparagraph.</p></div><h2><a name="h-4.4" id="h-4.4">4.4 Attribute values mustalways be quoted</a></h2><p>All attribute values must be quoted, even those which appearto be numeric.</p><div class="good"><p><strong><em>CORRECT: quoted attribute values</em></strong></p><p><table rows="3"></p></div><div class="bad"><p><strong><em>INCORRECT: unquoted attribute values</em></strong></p><p><table rows=3></p></div><h2><a name="h-4.5" id="h-4.5">4.5 AttributeMinimization</a></h2><p>XML does not support attribute minimization. Attribute-valuepairs must be written in full. Attribute names such as <code>compact</code> and <code>checked</code> cannot occur in elementswithout their value being specified.</p><div class="good"><p><strong><em>CORRECT: unminimized attributes</em></strong></p><p><dl compact="compact"></p></div><div class="bad"><p><strong><em>INCORRECT: minimized attributes</em></strong></p><p><dl compact></p></div><h2><a name="h-4.6" id="h-4.6">4.6 Empty Elements</a></h2><p>Empty elements must either have an end tag or the start tag must end with <code>/></code>. For instance,<code><br/></code> or <code><hr></hr></code>. See <ahref="#guidelines">HTML Compatibility Guidelines</a> for information on ways toensure this is backward compatible with HTML 4.0 user agents.</p><div class="good"><p><strong><em>CORRECT: terminated empty tags</em></strong></p><p><br/><hr/></p></div><div class="bad"><p><strong><em>INCORRECT: unterminated empty tags</em></strong></p><p><br><hr></p></div><h2><a name="h-4.7" id="h-4.7">4.7 Whitespace handling inattribute values</a></h2><p>In attribute values, user agents will strip leading andtrailing whitespace from attribute values and map sequencesof one or more whitespace characters (including line breaks) toa single inter-word space (an ASCII space character for westernscripts). See <a href="http://www.w3.org/TR/REC-xml#AVNormalize">Section 3.3.3</a> of <a href="#ref-xml">[XML]</a>.</p><h2><a name="h-4.8" id="h-4.8">4.8 Script and Styleelements</a></h2><p>In XHTML, the script and style elements are declared as having<code>#PCDATA</code> content. As a result, <code><</code> and<code>&</code> will be treated as the start of markup, andentities such as <code>&lt;</code> and <code>&amp;</code>will be recognized as entity references by the XML processor to<code><</code> and <code>&</code> respectively. Wrappingthe content of the script or style element within a <code>CDATA</code> marked section avoids the expansion of theseentities.</p><div class="good"><pre><script> <![CDATA[ ... unescaped script content ... ]]> </script></pre></div><p><code>CDATA</code> sections are recognized by the XMLprocessor and appear as nodes in the Document Object Model, see<a href= "http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-E067D597">Section 1.3</a> of the DOM Level 1 Recommendation <a href= "#ref-dom">[DOM]</a>.</p><p>An alternative is to use external script and styledocuments.</p><h2><a name="h-4.9" id="h-4.9">4.9 SGML exclusions</a></h2><p>SGML gives the writer of a DTD the ability to exclude specificelements from being contained within an element. Suchprohibitions (called "exclusions") are not possible in XML.</p><p>For example, the HTML 4.0 Strict DTD forbids the nesting of an'<code>a</code>' element within another '<code>a</code>' elementto any descendant depth. It is not possible to spell out suchprohibitions in XML. Even though these prohibitions cannot bedefined in the DTD, certain elements should not be nested. Asummary of such elements and the elements that should not benested in them is found in the normative <a href="#prohibitions">Appendix B</a>.</p><h2><a name="h-4.10" id="h-4.10">4.10 The elements with 'id' and 'name'attributes</a></h2><p>HTML 4.0 defined the <code>name</code> attribute for the elements<code>a</code>,<code>applet</code>, <code>frame</code>,<code>iframe</code>, <code>img</code>, and <code>map</code>.HTML 4.0 also introducedthe <code>id</code> attribute. Both of these attributes are designed to beused as fragment identifiers.</p><p>In XML, fragment identifiers are of type <code>ID</code>, andthere can only be a single attribute of type <code>ID</code> per element.Therefore, in XHTML 1.0 the <code>id</code>attribute is defined to be of type <code>ID</code>. In order toensure that XHTML 1.0 documents are well-structured XML documents, XHTML 1.0documents MUST use the <code>id</code> attribute when defining fragmentidentifiers, even on elements that historically have also had a<code>name</code> attribute.See the <a href="#guidelines">HTML CompatibilityGuidelines</a> for information on ensuring such anchors are backwardscompatible when serving XHTML documents as media type <code>text/html</code>.</p><p>Note that in XHTML 1.0, the <code>name</code> attribute of theseelements is formally deprecated, and will be removed in asubsequent version of XHTML.</p><!--OddPage--><h1><a name="issues" id="issues">5. Compatibility Issues</a></h1><p>Although there is no requirement for XHTML 1.0 documents to becompatible with existing user agents, in practice this is easy toaccomplish. Guidelines for creating compatible documents can befound in <a href="#guidelines">Appendix C</a>.</p><h2><a name="media" id="media">5.1 Internet Media Type</a></h2><p>As of the publication of this recommendation, the generalrecommended MIME labeling for XML-based applicationshas yet to be resolved.</p><p>However, XHTML Documents which follow the guidelines set forthin <a href="#guidelines">Appendix C</a>, "HTML Compatibility Guidelines" may belabeled with the Internet Media Type "text/html", as theyare compatible with most HTML browsers. This documentmakes no recommendation about MIME labeling of otherXHTML documents.</p><!--OddPage--><h1><a name="future" id="future">6. Future Directions</a></h1><p>XHTML 1.0 provides the basis for a family of document typesthat will extend and subset XHTML, in order to support a widerange of new devices and applications, by defining modules andspecifying a mechanism for combining these modules. Thismechanism will enable the extension and sub-setting of XHTML 1.0in a uniform way through the definition of new modules.</p><h2><a name="mods" id="mods">6.1 Modularizing HTML</a></h2><p>As the use of XHTML moves from the traditional desktop useragents to other platforms, it is clear that not all of the XHTMLelements will be required on all platforms. For example a handheld device or a cell-phone may only support a subset of XHTMLelements.</p><p>The process of modularization breaks XHTML up into a series ofsmaller element sets. These elements can then be recombined tomeet the needs of different communities.</p><p>These modules will be defined in a later W3C document.</p><h2><a name="extensions" id="extensions">6.2 Subsets andExtensibility</a></h2><p>Modularization brings with it several advantages:</p><ul><li><p>It provides a formal mechanism for sub-setting XHTML.</p></li><li><p>It provides a formal mechanism for extending XHTML.</p></li><li><p>It simplifies the transformation between document types.</p></li><li><p>It promotes the reuse of modules in new document types.</p></li></ul><h2><a name="profiles" id="profiles">6.3 DocumentProfiles</a></h2><p>A document profile specifies the syntax and semantics of a setof documents. Conformance to a document profile provides a basisfor interoperability guarantees. The document profile specifiesthe facilities required to process documents of that type, e.g.which image formats can be used, levels of scripting, style sheetsupport, and so on.</p><p>For product designers this enables various groups to definetheir own standard profile.</p><p>For authors this will obviate the need to write severaldifferent versions of documents for different clients.</p><p>For special groups such as chemists, medical doctors, ormathematicians this allows a special profile to be built usingstandard HTML elements plus a group of elements geared to thespecialist's needs.</p><!--OddPage--><h1><a name="appendices" id="appendices"></a><a name="dtds" id="dtds">Appendix A. DTDs</a></h1><p><b>This appendix is normative.</b></p><p>These DTDs and entity sets form a normative part of thisspecification. The complete set of DTD files together with an XMLdeclaration and SGML Open Catalog is included in the <a href= "xhtml1.zip">zip file</a> for this specification.</p><h2><a name="h-A1" id="h-A1">A.1 Document TypeDefinitions</a></h2><p>These DTDs approximate the HTML 4.0 DTDs. It is likely thatwhen the DTDs are modularized, a method of DTD construction willbe employed that corresponds more closely to HTML 4.0.</p><ul><li><p><a href="DTD/xhtml1-strict.dtd" type="text/plain">XHTML-1.0-Strict</a></p></li><li><p><a href="DTD/xhtml1-transitional.dtd" type="text/plain">XHTML-1.0-Transitional</a></p></li><li><p><a href="DTD/xhtml1-frameset.dtd" type="text/plain">XHTML-1.0-Frameset</a></p></li></ul><h2><a name="h-A2" id="h-A2">A.2 Entity Sets</a></h2><p>The XHTML entity sets are the same as for HTML 4.0, but havebeen modified to be valid XML 1.0 entity declarations. Note the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -