HTML4.01規範中英文對照-HTML基本數據類型(1)

6 Basic HTML data types

This section of the specification describes the basic data types that may appear as an element's content or an attribute's value.

For introductory information about reading the HTML DTD, please consult the SGML tutorial.

本部分描述了元素的內容裏以及屬性值中可以出現的基本數據類型。

關於閱讀HTML DTD的詳細介紹信息,請參閱"SGML教程"。

6.1 Case information

Each attribute definition includes information about the case-sensitivity of its values. The case information is presented with the following keys:

CS
The value is case-sensitive (i.e., user agents interpret "a" and "A" differently).
CI
The value is case-insensitive (i.e., user agents interpret "a" and "A" as the same).
CN
The value is not subject to case changes, e.g., because it is a number or a character from the document character set.
CA
The element or attribute definition itself gives case information.
CT
Consult the type definition for details about case-sensitivity.

If an attribute value is a list, the keys apply to every value in the list, unless otherwise indicated.

每個屬性的定義都包含了改屬性值是否大小寫敏感的信息。這些大小寫信息採用如下鍵值表示:

CS
值是大小寫敏感的(例如:用戶代理會對"a" 和"A" 採用不同的解析)。
CI
值是大小寫不敏感的 (例如:用戶代理會認爲 "a" 和"A" 是一樣的)。
CN
值爲大小寫中立,不會參與到大小寫變化,即不存在大小寫問題,例如:因爲是數字或者來自文檔字符集的字符。
CA
元素或者屬性定義本身會給出大小寫信息。
CT
從類型定義中獲取大小心敏感的詳細信息。

如果一個屬性的值是列表,那麼這些鍵值在沒有其他說明的情況下,將會應用到該列表內的每一個值。

6.2 SGML basic types

The document type definition specifies the syntax of HTML element content and attribute values using SGML tokens (e.g., PCDATA, CDATA, NAME, ID, etc.). See [ISO8879] for their full definitions. The following is a summary of key information:

文檔類型定義在描述HTML元素內容和屬性值時採用了SGML的詞彙(比如:PCDATA,CDATA,NAME,ID等)。請參見[ISO8879]來獲取他們的完整定義。下面是這些關鍵字的彙總信息:

  • CDATA is a sequence of characters from the document character set and may include character entities. User agents should interpret attribute values as follows:
    • Replace character entities with characters,
    • Ignore line feeds,
    • Replace each carriage return or tab with a single space.

    User agents may ignore leading and trailing white space in CDATA attribute values (e.g., "   myval   " may be interpreted as "myval"). Authors should not declare attribute values with leading or trailing white space.

    For some HTML 4 attributes with CDATA attribute values, the specification imposes further constraints on the set of legal values for the attribute that may not be expressed by the DTD.

    Although the STYLE and SCRIPT elements use CDATA for their data model, for these elements, CDATA must be handled differently by user agents. Markup and entities must be treated as raw text and passed to the application as is. The first occurrence of the character sequence "</" (end-tag open delimiter) is treated as terminating the end of the element's content. In valid documents, this would be the end tag for the element.

  • ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
  • IDREF and IDREFS are references to ID tokens defined by other attributes. IDREF is a single token and IDREFS is a space-separated list of tokens.
  • NUMBER tokens must contain at least one digit ([0-9]).

  • CDATA 是由來自文檔字符集的字符所組成的字符序列,並且這個序列裏可以包含字符實體。用戶代理應該以下面的方式來解析屬性值:
    • 將字符實體替換爲實際代表的字符。
    • 忽略換行符。
    • 將每一個回車或者製表符(tab)替換爲一個單一的空格。

    用戶代理可以忽略CDATA型屬性值頭部和尾部的所有空格,例如: "   myval   "可以被解析成 "myval"。 HTML的作者不應該聲明頭部和尾部有空格的屬性值。

    對於一些CDATA型的HTML 4 屬性值,本規範提供了進一步的取值限制,因爲這些限制沒有辦法用DTD來描述。

    雖然STYLESCRIPT 元素的數據模型採用CDATA型, 但是對於這些元素來說,用戶代理必須採用另外的方式來處理CDATA。標記和實體必須被當做原始文本來對待,並將其原封不動地傳遞到相應的應用。第一個字符序列"</" (結束標籤起始符) 被認爲是元素內容的結束。在一個有效的文檔中,這個字符序列應該是元素的結束標籤。

  • IDNAME 型數據的必須以字母([A-Za-z])開始,可以後跟任意多個字母,數字([0-9]),連詞符("-"),下劃線("_"),冒號 (":")以及句號 (".")。
  • IDREFIDREFS 是指向其他屬性定義的ID值的引用。IDREF 爲單一ID引用,而IDREFS是以空格分隔的ID列表。
  • NUMBER至少包含一個數字([0-9])。

6.3 Text strings

A number of attributes ( %Text; in the DTD) take text that is meant to be "human readable". For introductory information about attributes, please consult the tutorial discussion of attributes.

有一些屬性,在DTD中描述爲%Text參數實體,這些屬性將承載“人可讀的”文本信息。關於屬性的介紹信息,請參閱屬性教程式討論。

6.4 URIs

This specification uses the term URI as defined in [URI] (see also [RFC1630]).

Note that URIs include URLs (as defined in [RFC1738] and [RFC1808]).

Relative URIs are resolved to full URIs using a base URI. [RFC1808], section 3, defines the normative algorithm for this process. For more information about base URIs, please consult the section on base URIs in the chapter on links.

URIs are represented in the DTD by the parameter entity %URI;.

URIs in general are case-sensitive. There may be URIs, or parts of URIs, where case doesn't matter (e.g., machine names), but identifying these may not be easy. Users should always consider that URIs are case-sensitive (to be on the safe side).

Please consult the appendix for information about non-ASCII characters in URI attribute values.

本規範採用在[URI] 或者[RFC1630])中定義的屬於URI,即URI的語義與上述規範定義一致。

需要注意URI包含URL,URL在[RFC1738] and [RFC1808]中定義。

相對URI在基址URI的幫助下會被解析成完整URI。[RFC1808]以及本規範的第三部分都定義了正式這一過程的處理機制。有關基址URI的更多信息,請參閱本規範鏈接章節中關於基址URI部分。

在DTD中URI採用參數實體%URI;來表示。

一般來說,URI是大小寫敏感的。對於有些URI或者一個URI的默某些部分來說,大小寫是無關緊要的,例如:計算機名,但是標識出這種情況不是一件容易的事情。爲了安全起見,用戶應該總是把URI認爲是大小寫敏感的。

關於URI屬性內非ASCII字符的信息,請參閱相關附錄。

6.5 Colors

The attribute value type "color" (%Color;) refers to color definitions as specified in [SRGB]. A color value may either be a hexadecimal number (prefixed by a hash mark) or one of the following sixteen color names. The color names are case-insensitive.

Color names and sRGB values
Black = "#000000" Green = "#008000"
Silver = "#C0C0C0" Lime = "#00FF00"
Gray = "#808080" Olive = "#808000"
White = "#FFFFFF" Yellow = "#FFFF00"
Maroon = "#800000" Navy = "#000080"
Red = "#FF0000" Blue = "#0000FF"
Purple = "#800080" Teal = "#008080"
Fuchsia = "#FF00FF" Aqua = "#00FFFF"

Thus, the color values "#800080" and "Purple" both refer to the color purple.

"color"屬性值類型,在DTD中爲參數實體%Color;,用於對[SRGB]中定義顏色的引用。一個顏色值或者是一個以#開頭的十六進制數字,抑或是下面列表中給出的16個顏色名字。顏色名字是不區分大小寫的。


顏色名及sRGB數值
Black = "#000000" Green = "#008000"
Silver = "#C0C0C0" Lime = "#00FF00"
Gray = "#808080" Olive = "#808000"
White = "#FFFFFF" Yellow = "#FFFF00"
Maroon = "#800000" Navy = "#000080"
Red = "#FF0000" Blue = "#0000FF"
Purple = "#800080" Teal = "#008080"
Fuchsia = "#FF00FF" Aqua = "#00FFFF"

根據上面列表情況,我們知道顏色值 "#800080" 和"Purple"都引用到相同的深紫色。

6.5.1 Notes on using colors

Although colors can add significant amounts of information to documents and make them more readable, please consider the following guidelines when including color in your documents:

  • The use of HTML elements and attributes for specifying color is deprecated. You are encouraged to use style sheets instead.
  • Don't use color combinations that cause problems for people with color blindness in its various forms.
  • If you use a background p_w_picpath or set the background color, then be sure to set the various text colors as well.
  • Colors specified with the BODY and FONT elements and bgcolor on tables look different on different platforms (e.g., workstations, Macs, Windows, and LCD panels vs. CRTs), so you shouldn't rely entirely on a specific effect. In the future, support for the [SRGB] color model together with ICC color profiles should mitigate this problem.
  • When practical, adopt common conventions to minimize user confusion.
儘管顏色可以向文檔中加入大量的信息並且可以使文檔更具可讀性,但在文檔中包含顏色信息時請遵循下面列表給出的指引:
  • HTML中用於指定顏色的元素和屬性是不被推薦使用的。相反,使用樣式表是被鼓勵的。
  • 不要在文檔中使用導致有色盲/色弱缺陷的人出現識別問題的顏色組合。
  • 如果使用背景圖片或者是設置背景顏色,那麼一定也要對文本顏色進行設置。
  • 通過BODY,FONT元素以及TABLE元素的bgcolor屬性指定的顏色會在不同的平臺上有不同的視覺展現(比如: 工作站, Macs, Windows, 以及LCD面板或者CRT上都會有所不同), 所以不能完全依賴某種特殊的效果。在未來,同時支持[SRGB] 顏色模型以及ICC顏色配置將會解決這個問題。
  • 在實踐中, 應儘量採用通用的術語以使用戶儘可能不迷惑。

6.6 Lengths

HTML specifies three types of length values for attributes:

  1. Pixels: The value (%Pixels; in the DTD) is an integer that represents the number of pixels of the canvas (screen, paper). Thus, the value "50" means fifty pixels. For normative information about the definition of a pixel, please consult [CSS1].
  2. Length: The value (%Length; in the DTD) may be either a %Pixel; or a percentage of the available horizontal or vertical space. Thus, the value "50%" means half of the available space.
  3. MultiLength: The value ( %MultiLength; in the DTD) may be a %Length; or a relative length. A relative length has the form "i*", where "i" is an integer. When allotting space among elements competing for that space, user agents allot pixel and percentage lengths first, then divide up remaining available space among relative lengths. Each relative length receives a portion of the available space that is proportional to the integer preceding the "*". The value "*" is equivalent to "1*". Thus, if 60 pixels of space are available after the user agent allots pixel and percentage space, and the competing relative lengths are 1*, 2*, and 3*, the 1* will be alloted 10 pixels, the 2* will be alloted 20 pixels, and the 3* will be alloted 30 pixels.
Length values are case-neutral.

HTML描述了爲屬性值提供的如下三種類型的長度值:

  1. 點(Pixels): 在DTD中用參數實體%Pixels; 表示,其取值是一個整型數字,用於表示在畫布(屏幕或者紙張)上點的數量。因此, 值 "50" 意味着五十個點。有關pixel的正式定義信息,請參閱 [CSS1]
  2. 長度(Length): 在DTD中用參數實體%Length; 表示,它的值既可以是%Pixel; 也可以是在可用的水平或者垂直空間長度上的百分比。因此, 值"50%" 表示可用空間的一半。
  3. 多種長度(MultiLength): 在DTD中用參數實體 %MultiLength; 表示,其確實可以是 %Length; 也可以是一個相對長度。 相對長度具有類似 "i*"的形式,其中 "i" 是一個整數。在爲互相競爭展現空間的衆多元素分配空間時,用戶代理首先分配點型和百分比型長度,然後再按照相對長度對剩餘的空間進行分配。每一個相對長度 會按比例在剩餘的空間中的長度,其計算規則如下,得到嗎每個相對長度"*"前面整型數字,然後計算這些數字在剩餘空間中的比例,最後按比例計算相應長度。 值 "*" 等於"1*"。因此,如果在用戶代理分配了點型長度以及百分比長度後,有60個點的空間,而此時互相的競爭的相對長度是 1*, 2*, 和 3*, 1* 會分配到10個點, 2* 將會被分配到20點, 3* 將會被分配到30點。
長度值是大小寫中立的。

6.7 Content types (MIME types)

Note. A "media type" (defined in [RFC2045] and [RFC2046]) specifies the nature of a linked resource. This specification employs the term "content type" rather than "media type" in accordance with current usage. Furthermore, in this specification, "media type" may refer to the media where a user agent renders a document.

This type is represented in the DTD by %ContentType;.

 

Content types are case-insensitive.

 

Examples of content types include "text/html", "p_w_picpath/png", "p_w_picpath/gif", "video/mpeg", "text/css", and "audio/basic". For the current list of registered MIME types, please consult [MIMETYPES].

 

註釋。在[RFC2045][RFC2046]定 義的媒體類型(Media Type)是指一個連接資源的內在屬性。爲了符合當前的用法,本規範採用”內容類型(Content Type)“而不是”媒體類型(Media Type)“。進一步來說,在本規範中”媒體類型(Media Type)“可以用來表示用戶代理展現(繪製)文檔介質。

該類型在DTD中採用參數實體 %ContentType;表示。

內容類型是大小寫不敏感的。

內容類型的例子有:"text/html", "p_w_picpath/png", "p_w_picpath/gif", "video/mpeg", "text/css", and "audio/basic"。如果想要獲取當前登記註冊的MIEM類型,請參閱 [MIMETYPES]。

6.8 Language codes

The value of attributes whose type is a language code ( %LanguageCode in the DTD) refers to a language code as specified by [RFC1766], section 2. For information on specifying language codes in HTML, please consult the section on language codes. Whitespace is not allowed within the language-code.

Language codes are case-insensitive.

語言代碼類型的屬性值,在DTD中用參數實體 %LanguageCode 表示。其值指的是在[RFC1766]第二部分中定義的語言代碼。有關在HTML中指定語言代碼的更多信息,請參閱語言代碼部分。在語言代碼裏空格是不允許出現的。

語言代碼是大小寫不敏感的。


6.9 Character encodings

The "charset" attributes (%Charset in the DTD) refer to a character encoding as described in the section on character encodings. Values must be strings (e.g., "euc-jp") from the IANA registry (see [CHARSETS] for a complete list).

Names of character encodings are case-insensitive.

User agents must follow the steps set out in the section on specifying character encodings in order to determine the character encoding of an external resource.

在DTD中採用參數實體%Charset 定義的"charset"屬性,是指在字符編碼部分所描述的字符編碼機制。其取值必須是IANA中正式註冊登記的字符串(例如:"euc-jp")。請參閱[CHARSETS] 以獲得字符編碼的完整列表。

6.10 Single characters

Certain attributes call for a single character from the document character set. These attributes take the %Character type in the DTD.

Single characters may be specified with character references (e.g., "&amp;").

有一些屬性只需要一個單獨的文檔字符集字符。這些屬性擁有在DTD中的參數實體%Character類型。

單一字符可以用字符引用來表示。例如: "&amp;"。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章