<body>: The Document Body element - HTML: HyperText Markup Language 编辑

The HTML <body> Element represents the content of an HTML document. There can be only one <body> element in a document.

Content categoriesSectioning root.
Permitted contentFlow content.
Tag omissionThe start tag may be omitted if the first thing inside it is not a space character, comment, <script> element or <style> element. The end tag may be omitted if the <body> element has contents or has a start tag, and is not immediately followed by a comment.
Permitted parentsIt must be the second element of an <html> element.
Implicit ARIA roledocument
Permitted ARIA rolesNo role permitted
DOM interfaceHTMLBodyElement

Attributes

This element includes the global attributes.

alink This is an obsolete API and is no longer guaranteed to work.
Color of text for hyperlinks when selected. This method is non-conforming, use CSS color property in conjunction with the :active pseudo-class instead.
background This is an obsolete API and is no longer guaranteed to work.
URI of a image to use as a background. This method is non-conforming, use CSS background property on the element instead.
bgcolor This is an obsolete API and is no longer guaranteed to work.
Background color for the document. This method is non-conforming, use CSS background-color property on the element instead.
bottommargin This is an obsolete API and is no longer guaranteed to work.
The margin of the bottom of the body. This method is non-conforming, use CSS margin-bottom property on the element instead.
leftmargin This is an obsolete API and is no longer guaranteed to work.
The margin of the left of the body. This method is non-conforming, use CSS margin-left property on the element instead.
link This is an obsolete API and is no longer guaranteed to work.
Color of text for unvisited hypertext links. This method is non-conforming, use CSS color property in conjunction with the :link pseudo-class instead.
onafterprint
Function to call after the user has printed the document.
onbeforeprint
Function to call when the user requests printing of the document.
onbeforeunload
Function to call when the document is about to be unloaded.
onblur
Function to call when the document loses focus.
onerror
Function to call when the document fails to load properly.
onfocus
Function to call when the document receives focus.
onhashchange
Function to call when the fragment identifier part (starting with the hash ('#') character) of the document's current address has changed.
onlanguagechange This is an experimental API that should not be used in production code.
Function to call when the preferred languages changed.
onload
Function to call when the document has finished loading.
onmessage
Function to call when the document has received a message.
onoffline
Function to call when network communication has failed.
ononline
Function to call when network communication has been restored.
onpopstate
Function to call when the user has navigated session history.
onredo
Function to call when the user has moved forward in undo transaction history.
onresize
Function to call when the document has been resized.
onstorage
Function to call when the storage area has changed.
onundo
Function to call when the user has moved backward in undo transaction history.
onunload
Function to call when the document is going away.
rightmargin This is an obsolete API and is no longer guaranteed to work.
The margin of the right of the body. This method is non-conforming, use CSS margin-right property on the element instead.
text This is an obsolete API and is no longer guaranteed to work.
Foreground color of text. This method is non-conforming, use CSS color property on the element instead.
topmargin This is an obsolete API and is no longer guaranteed to work.
The margin of the top of the body. This method is non-conforming, use CSS margin-top property on the element instead.
vlink This is an obsolete API and is no longer guaranteed to work.
Color of text for visited hypertext links. This method is non-conforming, use CSS color property in conjunction with the :visited pseudo-class instead.

Example

<html>
  <head>
    <title>Document title</title>
  </head>
  <body>
    <p>This is a paragraph</p>
  </body>
</html>

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of '<body>' in that specification.
Living StandardChanged the list of non-conforming features.
HTML5
The definition of '<body>' in that specification.
RecommendationObsoleted the formerly deprecated attributes. Defined the behavior of the non-conforming and never standardized topmargin, leftmargin, rightmargin and bottommargin. Added the on* attributes.
HTML 4.01 Specification
The definition of '<body>' in that specification.
RecommendationDeprecated the alink, background, bgcolor, link, text and vlink attributes.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:114 次

字数:19929

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文