<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body --> <!ATTLIST BODY %attrs; -- %coreattrs, %i18n, %events -- %Script; #IMPLIED -- the document has been loaded -- onunload %Script; #IMPLIED -- the document has been removed -- >
Start tag: optional, End tag: optionalcss
開始標籤:可選,結束標籤:可選
html
Attribute definitions數據庫
屬性定義
編程
Attributes defined elsewherecanvas
在其餘地方定義的屬性
瀏覽器
The body of a document contains the document's content. The content may be presented by a user agent in a variety of ways. For example, for visual browsers, you can think of the body as a canvas where the content appears: text, p_w_picpaths, colors, graphics, etc. For audio user agents, the same content may be spoken. Since style sheets are now the preferred way to specify a document's presentation, the presentational attributes of BODY have been deprecated.app
文 檔的BODY承載文檔的內容。用戶代理可能以多種方式顯示BODY的內容。例如,對於可視化瀏覽器,能夠認爲BODY是一個用於繪製諸如:文本,圖片,顏 色,圖像等的畫布。對於音頻瀏覽器,一樣的內容將會被朗讀出來。如今,因爲樣式表做爲推薦的控制文檔展示的工具,BODY的全部展示相關的屬性都是不推薦 的。框架
DEPRECATED EXAMPLE:
The following HTML fragment illustrates the use of the deprecated attributes. It sets the background color of the canvas to white, the text foreground color to black, and the color of hyperlinks to red initially, fuchsia when activated, and maroon once visited.編程語言
不推薦的示例:ide
下面的HTML片斷展現了不推薦屬性的用法。它設置畫布的背景色爲白色,文本的前景色爲黑色以及未被訪問的超連接爲紅色,激活的超連接爲紫色,訪問過的超連接爲褐紫色。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <TITLE>A study of population dynamics</TITLE> </HEAD> <BODY bgcolor="white" text="black" link="red" alink="fuchsia" vlink="maroon">... document body... </BODY> </HTML>
Using style sheets, the same effect could be accomplished as follows:
採用樣式表,能夠得到一樣的效果:
<!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> <STYLE type="text/css"> BODY { background: white; color: black} A:link { color: red } A:visited { color: maroon } A:active { color: fuchsia } </STYLE> </HEAD> <BODY>
... document body... </BODY> </HTML>
Using external (linked) style sheets gives you the flexibility to change the presentation without revising the source HTML document:
外部(連接的)樣式表的使用提供了在不修改HTML文檔源代碼的狀況下改變展示效果的靈活性:
<!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> <LINK rel="stylesheet" type="text/css" href="smartstyle.css"> </HEAD> <BODY> ... document body... </BODY> </HTML>
Framesets and HTML bodies. Documents that contain framesets replace the BODY element by the FRAMESET element. Please consult the section on frames for more information.
Frameset和HTML BODY。在承載frameset的文檔中FRAMESET元素替代了BODY元素。有關框架的更多信息請參閱本規範的相應部分。
Attribute definitions
屬性定義
<P id="myparagraph"> This is a uniquely named paragraph.</P> <P id="yourparagraph"> This is also a uniquely named paragraph.</P>
The id attribute has several roles in HTML:
在HTML中id屬性擁有多個角色,具體以下:
The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML:
在另外一方面,class屬性爲一個元素賦予一個或多個class名字;也能夠說成是該元素屬於這些class。一個class名字能夠被多個元素實例共享。class屬性在HTML中擁有多個角色:
In the following example, the SPAN element is used in conjunction with the id and class attributes to markup document messages. Messages appear in both English and French versions.
下面例子中,SPAN元素與id和class屬性聯合使用來標記文檔消息。這些消息同時擁有英文和法文版本。
<!-- English messages --> <P><SPAN id="msg1" class="info" lang="en">Variable declared twice</SPAN> <P><SPAN id="msg2" class="warning" lang="en">Undeclared variable</SPAN> <P><SPAN id="msg3" class="error" lang="en">Bad syntax for variable name</SPAN>
<!-- French messages --> <P><SPAN id="msg1" class="info" lang="fr">Variable déclarée deux fois</SPAN> <P><SPAN id="msg2" class="warning" lang="fr">Variable indéfinie</SPAN> <P><SPAN id="msg3" class="error" lang="fr">Erreur de syntaxe pour variable</SPAN>
The following CSS style rules would tell visual user agents to display informational messages in green, warning messages in yellow, and error messages in red:
下面的CSS樣式規則告知可視化瀏覽器用綠色顯示提示性消息,用×××顯示警告消息以及用紅色顯示錯誤消息:
SPAN.info { color: green } SPAN.warning { color: yellow } SPAN.error { color: red }
Note that the French "msg1" and the English "msg1" may not appear in the same document since they share the same id value. Authors may make further use of the id attribute to refine the presentation of individual messages, make them target anchors, etc.
請注意,法文的「msg1」和英文的「msg1」因爲共享了同一個id值,不能夠在同一個文檔中同時出現。做者能夠進一步應用id屬性來改進單個消息的展示,以及將它們做爲目標錨定點等。
Almost every HTML element may be assigned identifier and class information.
幾乎全部的HTML元素均可以被賦予標識符以及class信息。
Suppose, for example, that we are writing a document about a programming language. The document is to include a number of preformatted examples. We use the PRE element to format the examples. We also assign a background color (green) to all instances of the PRE element belonging to the class "example".
例如,設想一下咱們正在撰寫一個關於編程語言的文檔。在文檔中準備包含一些預格式化處理過的示例。咱們使用PRE元素來格式化這些示例。對於屬於class"example"的PRE元素實例的背景顏色設置成綠色。
<HEAD> <TITLE>
... document title ...
</TITLE> <STYLE type="text/css"> PRE.example { background : green } </STYLE> </HEAD> <BODY><PRE class="example" id="example-1"> ...example code here... </PRE> </BODY>
By setting the id attribute for this example, we can
(1) create a hyperlink to it and
(2) override class style information with instance style information.
經過爲該示例設置id屬性,咱們能夠
(1)建立一個連接到它的超連接以及
(2)用實例樣式信息覆蓋class樣式信息。
Note. The id attribute shares the same name space as the name attribute when used for anchor names. Please consult the section on anchors with id for more information.
註釋。在做爲錨定點使用時,id屬性和name屬性共享同一個名字空間。請參閱」使用id錨定部分「以獲取更多信息。
Certain HTML elements that may appear in BODY are said to be "block-level" while others are "inline" (also known as "text level"). The distinction is founded on several notions:
在BODY中容許出現的HTML元素中有一部分被稱爲塊級別元素,另外一部分稱爲行內元素(也叫作文本級別元素)。他們的區別表如今以下方面:
Style sheets provide the means to specify the rendering of arbitrary elements, including whether an element is rendered as block or inline. In some cases, such as an inline style for list elements, this may be appropriate, but generally speaking, authors are discouraged from overriding the conventional interpretation of HTML elements in this way.
樣式表提供了,包括指定一個元素是做爲塊級別仍是行內來展示在內的,控制元素繪製的方法。在一些狀況下,如列表元素的行內樣式,這樣作多是合適的,但通常來講,做者不該該覆蓋HTML元素約定俗成的解釋。
The alteration of the traditional presentation idioms for block level and inline elements also has an impact on the bidirectional text algorithm. See the section on the effect of style sheets on bidirectionality for more information.
修改塊級別元素以及行內元素傳統的展示機制,同時會對雙向文本機制存在影響。請參看」樣式表對雙向文本的影響「部分獲取更多信息。