Xhtml 简明教程
XHTML - Version 1.1
W3C 帮助互联网内容开发社区从错误、非标准标记的时代移到了结构良好、有效的 XML 世界。在 XHTML 1.0 中,这一举动因旨在提供将现有的 HTML 4(或更早版本)内容轻松迁移至 XHTML 和 XML 而得以缓解。
The W3C has helped move the internet content-development community from the days of malformed, non-standard mark-up into the well-formed, valid world of XML. In XHTML 1.0, this move was moderated by the goal of providing easy migration of existing HTML 4 (or earlier) based content to XHTML and XML.
W3C 从 XHTML 家族中删除了对不推荐使用的元素和属性的支持。这些元素和属性在很大程度上具有以演示为导向的功能,而这更适合通过样式表或特定于客户端的默认行为来处理。
The W3C has removed support for deprecated elements and attributes from the XHTML family. These elements and attributes had largely presentation-oriented functionality that is better handled via style sheets or client-specific default behavior.
现在,W3C 的 HTML 工作组已定义了一种初始文档类型,仅基于 XHTML 1.1 模块。此文档类型旨在可移植至广泛的客户端设备,并且适用于大多数互联网内容。
Now the W3C’s HTML Working Group has defined an initial document type based solely upon modules which are XHTML 1.1. This document type is designed to be portable to a broad collection of client devices, and applicable to the majority of internet content.
Document Conformance
XHTML 1.1 为必须满足以下所有条件的严格符合标准的 XHTML 文档提供了定义 -
The XHTML 1.1 provides a definition of strictly conforming XHTML documents which MUST meet all the following criteria −
-
The document MUST conform to the constraints expressed in XHTML 1.1 Document Type Definition.
-
The root element of the document MUST be <html>.
-
The root element of the document MUST designate the XHTML namespace using the xmlns attribute.
-
The root element MAY also contain a schema location attribute as defined in the XML Schema.
根元素之前必须在文档中有一个 DOCTYPE 声明。如果存在,则 DOCTYPE 声明中包含的公共标识符必须引用 XHTML 1.1 文档类型定义中找到的 DTD。
There MUST be a DOCTYPE declaration in the document prior to the root element. If it is present, the public identifier included in the DOCTYPE declaration MUST refer the DTD found in XHTML 1.1 Document Type Definition.
以下是对 XHTML 1.1 文档的示例 -
Here is an example of an XHTML 1.1 document −
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" xml:lang="en">
<head>
<title>This is the document title</title>
</head>
<body>
<p>Moved to <a href="http://example.org/">example.org</a>.</p>
</body>
</html>
Note − 此示例中包含 XML 声明。并非所有 XML 文档都需要使用上述 XML 声明。强烈建议 XHTML 文档作者在所有文档中使用 XML 声明。当文档的字符编码不是默认的 UTF-8 或 UTF-16 时,则需要声明。
Note − In this example, the XML declaration is included. An XML declaration such as the one above is not required in all XML documents. XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16.
XHTML 1.1 Modules
XHTML 1.1 文档类型包含以下 XHTML 模块。
The XHTML 1.1 document type is made up of the following XHTML modules.
Structure Module - 结构模块为 XHTML 定义主要结构元素。这些元素有效地作为许多 XHTML 系列文档类型的内容模型的基础。此模块中包含的元素和属性有 body、head、html 和 title。
Structure Module − The Structure Module defines the major structural elements for XHTML. These elements effectively act as the basis for the content model of many XHTML family document types. The elements and attributes included in this module are − body, head, html, and title.
Text Module - 此模块定义所有基本文本容器元素、属性及其内容模型 - abbr、acronym、address、blockquote、br、cite、code、dfn、div、em、h1、h2、h3、h4、h5、h6、kbd、p、pre、q、 samp、span、strong 和 var。
Text Module − This module defines all of the basic text container elements, attributes, and their content model − abbr, acronym, address, blockquote, br, cite, code, dfn, div, em, h1, h2, h3, h4, h5, h6, kbd, p, pre, q, samp, span, strong, and var.
Hypertext Module - 超文本模块提供用于定义到其他资源的超文本链接的元素。此模块支持元素 a。
Hypertext Module − The Hypertext Module provides the element that is used to define hypertext links to other resources. This module supports element a.
List Module - 正如其名称所暗示的,列表模块提供以列表为导向的元素。具体来说,List Module 支持以下元素和属性:dl、dt、dd、ol、ul 和 li。
List Module − As its name suggests, the List Module provides list-oriented elements. Specifically, the List Module supports the following elements and attributes − dl, dt, dd, ol, ul, and li.
Object Module - Object Module 提供用于通用的对象包含的元素。具体来说,Object Module 支持 - object 和 param。
Object Module − The Object Module provides elements for general-purpose object inclusion. Specifically, the Object Module supports − object and param.
Presentation Module - 此模块定义元素、属性和与简单的表示相关标记的极小内容模型——b、big、hr、i、small、sub、sup 和 tt。
Presentation Module − This module defines elements, attributes, and a minimal content model for simple presentation-related markup − b, big, hr, i, small, sub, sup, and tt.
Edit Module - 此模块定义元素和属性,用于与编辑相关的标记——del 和 ins。
Edit Module − This module defines elements and attributes for use in editing-related markup − del and ins.
Bidirectional Text Module - 双向文本模块定义了一个元素,该元素可用于为元素的内容声明双向规则——bdo。
Bidirectional Text Module − The Bi-directional Text module defines an element that can be used to declare the bi-directional rules for the element’s content − bdo.
Forms Module - 它提供 HTML 4.0 中找到的所有表单功能。具体来说,它支持——button、fieldset、form、input、label、legend、select、optgroup、option 和 textarea。
Forms Module − It provides all the form features found in HTML 4.0. Specifically, it supports − button, fieldset, form, input, label, legend, select, optgroup, option, and textarea.
Table Module - 它支持以下元素、属性和内容模型 - caption、col、colgroup、table、tbody、td、tfoot、th、thead 和 tr。
Table Module − It supports the following elements, attributes, and content model − caption, col, colgroup, table, tbody, td, tfoot, th, thead, and tr.
Image Module - 它提供基本的图像嵌入,并且可以独立地用于某些客户端图像映射实现。它支持元素——img。
Image Module − It provides basic image embedding and may be used in some implementations of client side image maps independently. It supports the element − img.
Client-side Image Map Module - 它为客户端图像映射提供元素——area 和 map。
Client-side Image Map Module − It provides elements for client side image maps − area and map.
Server-side Image Map Module - 它支持图像选择和选择坐标的传输。服务器端图像映射模块支持——img 上的属性 ismap。
Server-side Image Map Module − It provides support for image-selection and transmission of selection coordinates. The Server-side Image Map Module supports − attribute ismap on img.
Intrinsic Events Module - 它支持 XHTML 事件中讨论的所有事件。
Intrinsic Events Module − It supports all the events discussed in XHTML Events.
Meta information Module - 元信息模块定义了一个元素,该元素描述了文档的声明部分中的信息。它包括元素 meta。
Meta information Module − The Meta information Module defines an element that describes information within the declarative portion of a document. It includes element meta.
Scripting Module - 它定义了用于包含与可执行脚本或缺乏对可执行脚本的支持相关的信息的元素。此模块中包含的元素和属性有 - noscript 和 script。
Scripting Module − It defines the elements used to contain information pertaining to executable scripts or the lack of support for executable scripts. Elements and attributes included in this module are − noscript and script.
Style Sheet Module - 它定义了在声明内部样式表时使用的元素。此模块定义的元素和属性是 - style。
Style Sheet Module − It defines an element to be used when declaring internal style sheets. The element and attribute defined by this module is − style.
Style Attribute Module (Deprecated) - 它定义了 style 属性。
Style Attribute Module (Deprecated) − It defines the style attribute.
Link Module − 它定义了一个可以用来定义外部资源链接的元素。它支持链接元素。
Link Module − It defines an element that can be used to define links to external resources. It supports link element.
Base Module − 它定义了一个可以用来定义基 URI 的元素,文档中的相对 URI 将从此基 URI 进行解析。此模块中包含的元素和属性为 − base。
Base Module − It defines an element that can be used to define a base URI against which relative URIs in the document are resolved. The element and attribute included in this module is − base.
Ruby Annotation Module − XHTML 也使用了在 RUBY 中定义的 Ruby 注释模块,并支持 − ruby、rbc、rtc、rb、rt 和 rp。
Ruby Annotation Module − XHTML also uses the Ruby Annotation module as defined in RUBY and supports − ruby, rbc, rtc, rb, rt, and rp.
Changes from XHTML 1.0 Strict
本节描述了 XHTML 1.1 和 XHTML 1.0 Strict 之间的区别。XHTML 1.1 代表已从 HTML 4 和 XHTML 1.0 中删除的内容。
This section describes the differences between XHTML 1.1 and XHTML 1.0 Strict. XHTML 1.1 represents a departure from both HTML 4 and XHTML 1.0.
-
The most significant is the removal of features that were deprecated.
-
The changes can be summarized as follows −
-
On every element, the lang attribute has been removed in favor of the xml:lang attribute.
-
On the <a> and <map> elements, the name attribute has been removed in favor of the id attribute.
-
The ruby collection of elements has been added.