docs.rodeo

MDN Web Docs mirror

: The Document Body element

{{HTMLSidebar}} 

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

Attributes

This element includes the global attributes, event attributes, and deprecated attributes:

Event attributes

[!NOTE] Each of the below event attribute names is linked to its equivalent {{domxref("Window")}}  interface event. You can listen to these events using addEventListener() instead of adding the oneventname attribute to the <body> element.

Deprecated attributes

[!WARNING] Do not use these deprecated attributes; opt for the CSS alternatives listed with each deprecated attribute instead.

Examples

<html lang="en">
  <head>
    <title>Document title</title>
  </head>
  <body>
    <p>
      The <code>&lt;body&gt;</code> HTML element represents the content of an
      HTML document. There can be only one <code>&lt;body&gt;</code> element in
      a document.
    </p>
  </body>
</html>

Result

{{EmbedLiveSample('Example')}} 

Technical summary

Content categories None.
Permitted content Flow content.
Tag omission The start tag may be omitted if the first thing inside it is not a space character, comment, `{{HTMLElement("script")}}`  element or `{{HTMLElement("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 parents It must be the second element of an `{{HTMLElement("html")}}`  element.
Implicit ARIA role generic
Permitted ARIA roles No role permitted
DOM interface `{{domxref("HTMLBodyElement")}}` 
  • The <body> element exposes the `{{domxref("HTMLBodyElement")}}`  interface.
  • You can access the <body> element through the `{{domxref("document.body")}}`  property.

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN