HTML4.01規範-HTML文檔的頂層結構(1)

7 The global structure of an HTML document

7.1 Introduction to the structure of an HTML document

An HTML 4 document is composed of three parts:安全

  1. a line containing HTML version information,
  2. a declarative header section (delimited by the HEAD element),
  3. a body, which contains the document's actual content. The body may be implemented by the BODY element or the FRAMESET element.

一個HTML 4文檔由以下三個部分組成:網絡

  1. 含有HTML 版本信息的文本行,
  2. 聲明性質的文檔頭部(由HEAD元素框定),
  3. 承載文檔實際內容的文檔體。 文檔體能夠經過 BODY 元素或者FRAMESET 元素實現。

White space (spaces, newlines, tabs, and comments) may appear before or after each section. Sections 2 and 3 should be delimited by the HTML element.app

在每部分的先後能夠出現以空格,換行符,製表符以及註釋組成的空白空間。第2部分和第3部分應該由HTML元素來框定。框架

Here's an example of a simple HTML document:ide

下面是一個簡單的HTML文檔的例子:工具

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<HTML>

   <HEAD>
 <TITLE>My first HTML document</TITLE>
   
</HEAD>
 <BODY>
      
<P>Hello world!

   </BODY>

</HTML>

7.2 HTML version information

A valid HTML document declares what version of HTML is used in the document. The document type declaration names the document type definition (DTD) in use for the document (see [ISO8879]).ui

一個有效的文檔應該聲明聲明其使用HTML的哪一個版本。文檔類型聲明命名了文檔使用的文檔定義類型(請參見[ISO8879])。this

HTML 4.01 specifies three DTDs, so authors must include one of the following document type declarations in their documents. The DTDs vary in the elements they support.

HTML4.01給出了三個DTD,HTML文檔做者必須在他們的文檔中包含其中的一個。這些DTD在他們支持的元素上有差別:

  • The HTML 4.01 Strict DTD includes all elements and attributes that have not been deprecated or do not appear in frameset documents. For documents that use this DTD, use this document type declaration:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
    
  • The HTML 4.01 Transitional DTD includes everything in the strict DTD plus deprecated elements and attributes (most of which concern visual presentation). For documents that use this DTD, use this document type declaration:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
    
  • The HTML 4.01 Frameset DTD includes everything in the transitional DTD plus frames as well. For documents that use this DTD, use this document type declaration:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
            "http://www.w3.org/TR/html4/frameset.dtd">
    
  • HTML 4.01 嚴格型DTD  該DTD包含全部沒有被不推薦的以及在框架集合文檔中沒有出現的元素和屬性。對於那些使用該DTD的文檔,應該使用下述的文檔類型聲明:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
    
  • The HTML 4.01 過渡型DTD 該DTD在嚴格型DTD基礎上增長了不被推薦的元素和屬性。這些不被推薦的元素和屬性絕大部分是有關視覺展示的。對於那些使用該DTD的文檔, 應該使用下述文檔類型聲明:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
    
  • The HTML 4.01 框架集合DTD 該DTD在過渡型DTD基礎上增長了有關框架的元素和屬性。對於那些使用該種類型DTD的文檔,應該使用以下形式的文檔聲明:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
            "http://www.w3.org/TR/html4/frameset.dtd">
    

The URI in each document type declaration allows user agents to download the DTD and any entity sets that are needed. The following (relative) URIs refer to DTDs and entity sets for HTML 4:

根據文檔類型聲明中的URI,用戶代理能夠下載相應的DTD以及它所須要的任何實體集合。下面的(相對)URI用於指定HTML 4的全部DTD和實體集合:

The binding between public identifiers and files can be specified using a catalog file following the format recommended by the Oasis Open Consortium (see [OASISOPEN]). A sample catalog file for HTML 4.01 is included at the beginning of the section on SGML reference information for HTML. The last two letters of the declaration indicate the language of the DTD. For HTML, this is always English ("EN").

public標識符與DTD文件之間的綁定能夠用符合Oasis 開放聯盟建議格式的目錄文件來進行指定。在SGML引用信息部分的最開始包含了一個HTML 4.01的例子目錄文件。聲明中最後兩個字符表示DTD的書寫語言。對於HTML來講,永遠是英語,因此這兩個字符應該老是「EN」。

Note. As of the 24 December version of HTML 4.01, the HTML Working Group commits to the following policy:

  • Any changes to future HTML 4 DTDs will not invalidate documents that conform to the DTDs of the present specification. The HTML Working Group reserves the right to correct known bugs.
  • Software conforming to the DTDs of the present specification may ignore features of future HTML 4 DTDs that it does not recognize.

This means that in a document type declaration, authors may safely use a system identifier that refers to the latest version of an HTML 4 DTD. Authors may also choose to use a system identifier that refers to a specific (dated) version of an HTML 4 DTD when validation to that particular DTD is required. W3C will make every effort to make archival documents indefinitely available at their original address in their original form.

註釋。在HTML4.01的12月24日版本定稿時,HTML工做組提交了以下的原則:

  • 對於將來HTML 4DTD的任何更改都不會使符合本規範中所描述DTD的文檔失效。HTML工做組保留修正錯誤的權力。
  • 符合本規範DTD的應用軟件能夠忽略將來HTML 4 DTD 中其不能識別的特性。
這意味着HTML的做者能夠在文檔類型聲明中 安全地使用引用到HTML 4最新版本DTD的系統標識符。在須要根據某個特定的DTD對文檔進行驗證時,HTML做者也能夠選擇指向特定(舊)版本HTML 4 DTD的系統標識符。W3C將盡力保證歸檔的全部文件永遠以他們最初的格式存放在他們最初的地址,並永遠可用。

7.3 The HTML element

<!ENTITY % html.content "HEAD, BODY">


<!ELEMENT HTML O O (%html.content;)    -- 文檔根元素 -->

<!ATTLIST HTML
  %i18n;                               -- lang, dir --
  >

start tag:optional,end tag:optional

開始標籤: 可選, 結束標籤: 可選

Attribute definitions

屬性定義

version = cdata [CN]
Deprecated. The value of this attribute specifies which HTML DTD version governs the current document. This attribute has been deprecated because it is redundant with version information provided by the document type declaration
不推薦。該屬性屬性值用於指定HTML DTD 的哪一個版本管理當前文檔。因爲在文檔定義聲明中一樣擁有版本信息,該屬性就變得多餘了。因此該屬性被不推薦使用。

Attributes defined elsewhere

在其餘地方定義的屬性

After document type declaration, the remainder of an HTML document is contained by the HTML element. Thus, a typical HTML document has this structure:

在文檔類型聲明以後,HTML文檔的剩餘部分由HTML元素承載,一個典型的HTML文檔擁有以下結構:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<HTML>

...The head, body, etc. goes here...
 </HTML>

7.4 The document head

7.4.1 The HEAD element

<!-- %head.misc; defined earlier on as "SCRIPT|STYLE|META|LINK|OBJECT" -->

<!ENTITY % head.content "TITLE & BASE?">

<!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head -->

<!ATTLIST HEAD

  %i18n;                               -- lang, dir --

  profile     %URI;          #IMPLIED  -- named dictionary of meta info --
  >

start tag:optional,end tag:optional

開始標籤: 可選, 結束標籤: 可選

Attribute definations

屬性定義

profile = uri [CT]
This attribute specifies the location of one or more meta data profiles, separated by white space. For future extensions, user agents should consider the value to be a list even though this specification only considers the first URI to be significant. Profiles are discussed below in the section on meta data
該屬性指定了一個或者多個以空白符間隔的元數據profile的地址。雖然本規範只關注第一個URI,但爲了未來的擴展,用戶代理應該將該屬性值當作list來處理。Profile在本章的後續有關元數據部分討論。

Attributes defined elsewhere

在其餘地方定義的屬性

The HEAD element contains information about the current document, such as its title, keywords that may be useful to search engines, and other data that is not considered document content. User agents do not generally render elements that appear in the HEAD as content. They may, however, make information in the HEAD available to users through other mechanisms.

HEAD元素承載關於當前文檔中諸如:標題,對搜索引擎有用的關鍵字以及其餘與文檔內容無關的數據。用戶代理一般不顯示在HEAD內出現的元素。然而,他們能夠採用其餘的機制將這些HEAD元素內的信息提供給用戶。

7.4.2 The TITLE element

<!-- The TITLE element is not considered part of the flow of text.
       It should be displayed, for example as the page header or
       window title. Exactly one title is required per document.
    -->
<!ELEMENT TITLE - - (#PCDATA) -(%head.misc;) -- document title -->
 <!ATTLIST TITLE %i18n>

Start tag: required, End tag: required

開始標籤:必須,結束標籤:必須

Attributes defined elsewhere

在其餘地方定義的屬性

Every HTML document must have a TITLE element in the HEAD section.

每個HTML文檔都必須在HEAD部分有一個TITLE元素。

Authors should use the TITLE element to identify the contents of a document. Since users often consult documents out of context, authors should provide context-rich titles. Thus, instead of a title such as "Introduction", which doesn't provide much contextual background, authors should supply a title such as "Introduction to Medieval Bee-Keeping" instead.

HTML文檔做者應該使用TITLE元素來標識文檔的內容。因爲用戶常常會在語境意外獲取文檔,因此做者應該提供富含語境信息的標題。例如,做者不該該提供像「Introduction」這樣的基本沒有語境背景的標題,而應該提供諸如「Introduction to Medieval Bee-Keeping」之類的標題。

For reasons of accessibility, user agents must always make the content of the TITLE element available to users (including TITLE elements that occur in frames). The mechanism for doing so depends on the user agent (e.g., as a caption, spoken).

基於可訪問性的緣由,用戶代理在任何狀況下都必須將TITLE元素(包括出如今框架Frame內的TITLEY元素)的內容展示給最終用戶。展示的機制依賴於用戶代理自己的實現,好比做爲題目或者轉化成語音播放。

Titles may contain character entities (for accented characters, special characters, etc.), but may not contain other markup (including comments). Here is a sample document title:

標題內爲了包含本土字符以及特殊字符等信息,可使用字符實體,可是不能在標題內出現其餘的標記(包括註釋在內)。下面是一個文檔標題的例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<HTML>

<HEAD>

<TITLE>A study of population dynamics</TITLE>

... other head elements...
</HEAD>
<BODY>
 ... document body...
</BODY>
</HTML>

7.4.3 The title attribute

Attribute definitions

title = text [CS]
This attribute offers advisory information about the element for which it is set.
屬性定義
title = text [CS]
此屬性爲其所修飾的元素提供諮詢顧問信息。

Unlike the TITLE element, which provides information about an entire document and may only appear once, the title attribute may annotate any number of elements. Please consult an element's definition to verify that it supports this attribute.

和TITLE元素爲整個文檔提供信息而且只能出現一次不同,titles屬性能夠標註任意數量的元素。請參與元素的定義信息以確認它們是否支持該屬性。

Values of the title attribute may be rendered by user agents in a variety of ways. For instance, visual browsers frequently display the title as a "tool tip" (a short message that appears when the pointing device pauses over an object). Audio user agents may speak the title information in a similar context. For example, setting the attribute on a link allows user agents (visual and non-visual) to tell users about the nature of the linked resource:

title 屬性的值可能會被用戶代理採用多種方式展示。好比,可視化瀏覽器絕大多數狀況下會將title顯示成一個工具提示(當點設備在對象上停留時出現的簡短信 息)。音頻用戶代理可能會採用人工語音讀出該標題信息。舉個例子,在一個link上這是該屬性將容許用戶代理(包括可視化的及非可視化的)告知用戶有關鏈 接資源的性質:

...some text...

Here's a photo of 
<A href="http://someplace.com/neatstuff.gif" title="Me scuba diving">

me scuba diving last summer
</A>

...some more text...

The title attribute has an additional role when used with the LINK element to designate an external style sheet. Please consult the section on links and style sheets for details.

在其修飾的LINK元素指向一個外部樣式表時,title屬性擁有一個附加的角色。請參與連接與樣式表部分以獲取詳細信息。

Note. To improve the quality of speech synthesis for cases handled poorly by standard techniques, future versions of HTML may include an attribute for encoding phonemic and prosodic information.

註釋。在某些標準技術不能很好處理的狀況下,爲了改善語音合成器的質量,在將來的HTML版本中可能會引入一個用於編碼語素及韻律信息的屬性。

7.4.4 Meta data

Note. The W3C Resource Description Framework (see [RDF10]) became a W3C Recommendation in February 1999. RDF allows authors to specify machine-readable metadata about HTML documents and other network-accessible resources.

註釋。W3C資源描述框架(RDF10)在1999年2月份成爲了W3C的官方建議。RDF 容許做者指定關於HTML文檔以及其餘網絡可訪問資源的元數據,該元數據是機器可讀的。

HTML lets authors specify meta data -- information about a document rather than document content -- in a variety of ways.

HTML容許做者採用多種方式指定元數據,元數據是關於文檔的信息而不是文檔內容自己。

For example, to specify the author of a document, one may use the META element as follows:

<META name="Author" content="Dave Raggett">

The META element specifies a property (here "Author") and assigns a value to it (here "Dave Raggett").

例如,爲了指定文檔的做者,可使用以下形式的META元素:

<META name="Author" content="Dave Raggett">

META元素指定了一個屬性(這裏是"Author")以及給該屬性賦值(這裏是「Dave Raggett 」)。

This specification does not define a set of legal meta data properties. The meaning of a property and the set of legal values for that property should be defined in a reference lexicon called a profile. For example, a profile designed to help search engines index documents might define properties such as "author", "copyright", "keywords", etc.

本規範沒有定義元數據屬性的合法集。屬性的含義以及該屬性的合法取值應該在成爲profile的參考詞彙中定義。例如,一個用於幫助搜索引擎索引文檔的profile可能定義諸如 "author", "copyright", "keywords"等的屬性。

Specifying meta data

指定元數據

In general, specifying meta data involves two steps:

  1. Declaring a property and a value for that property. This may be done in two ways:
    1. From within a document, via the META element.
    2. From outside a document, by linking to meta data via the LINK element (see the section on link types).
  2. Referring to a profile where the property and its legal values are defined. To designate a profile, use the profile attribute of the HEAD element.
一把來講,指定元數據涉及以下兩個步驟:
  1. 聲明一個屬性及相應的取值。這能夠經過以下兩種方式來作到:
    1. 在文檔內,經過META元素
    2. 在文檔外,經過LINK元素連接元數據(請參與連接類型部分)。
  2. 引用到一個profile,該profile包含了改屬性及其合法取值的定義。使用HEAD元素的profile屬性來指定一個profile。

Note that since a profile is defined for the HEAD element, the same profile applies to all META and LINK elements in the document head.

請注意因爲profile在HEAD元素中定義,文檔頭內的全部META及LINK元素都應該共享一樣的profile。

User agents are not required to support meta data mechanisms. For those that choose to support meta data, this specification does not define how meta data should be interpreted.

用戶代理不須要必定支持元數據機制。對於那些選擇支持元數據的用戶代理,本規範沒有定義元數據應該如何被解讀。

相關文章
相關標籤/搜索