<!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.
修改块级别元素以及行内元素传统的展示机制,同时会对双向文本机制存在影响。请参看”样式表对双向文本的影响“部分获取更多信息。