Contentshtml
本章內容瀏覽器
An HTML 4 document is composed of three parts:安全
一個HTML 4文檔由以下三個部分組成:網絡
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>
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在他們支持的元素上有差別:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.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:
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工做組提交了以下的原則:
<!ENTITY % html.content "HEAD, BODY"> <!ELEMENT HTML O O (%html.content;) -- 文檔根元素 --> <!ATTLIST HTML %i18n; -- lang, dir -- >
start tag:optional,end tag:optional
開始標籤: 可選, 結束標籤: 可選
Attribute definitions
屬性定義
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>
<!-- %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
屬性定義
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元素內的信息提供給用戶。
<!-- 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>
Attribute definitions
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版本中可能會引入一個用於編碼語素及韻律信息的屬性。
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"等的屬性。
指定元數據
In general, specifying meta data involves two steps:
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.
用戶代理不須要必定支持元數據機制。對於那些選擇支持元數據的用戶代理,本規範沒有定義元數據應該如何被解讀。