This reference is built into PageRIJ — a live HTML, CSS & SVG authoring and learning environment.

HTML <body> element

The <body> element represents the document's content. It is the second child element of <html>, following <head>, which holds the document's metadata.

A document has one <body> element. It contains text, headings, images, forms, and other page content. Some of its contents may not be visible: hidden elements, <script> elements, and <template> elements can also occur there.

The body is a common place to apply a CSS class for a page-wide presentation, and scripts can access it through document.body. Its role is to contain the document’s content, even when HTML’s rules allow its opening or closing tag to be omitted from the source.

Besides global attributes, the body supports a set of window-event handler attributes. For example, onload handles the window’s load event and onafterprint handles the event after printing. These handlers relate to the document’s window rather than merely to a generic container.

The small document below contains one <h1> in its body. The visual column shows that body content.

Attributes: GLOBALS and window-event handler attributes, including onload and onafterprint.

Typical layout:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Welcome</title>
</head>
<body>
  <h1>Welcome</h1>
</body>
</html>
Visual representation:

Welcome