<body>

<body> contains the document’s flow content: text, headings, landmarks, links, controls, and media. It follows head inside html. Use one body per document.

A complete document

A complete HTML documentLink

HTML and CSS

HTML

<main>
  <h1>Gardening notes</h1>
  <p>Keep seedlings watered while their roots establish.</p>
</main>

CSS

Edit HTML or CSS to update the preview as you type. Copy code snippet copies the selected tab. Preview spacing and font defaults are not included.

Placement and attributes

Use main for the primary content and semantic elements inside it. A body is not a substitute for a main landmark. Global attributes apply; document-level event handler attributes also exist, but a separate script is easier to maintain.

Old presentational attributes such as bgcolor and text are obsolete. Use background-color and color in CSS instead.

Inspect the result

Inspect the document’s accessibility tree. Find the main landmark, the level-1 heading, and the paragraph. Confirm that the metadata title is separate from the visible body heading.

Common mistakes

Do not insert a second document root, head, or body into an existing article and expect it to create a nested document. Use an iframe when a demonstration needs its own document. Browsers repair malformed HTML; the repaired DOM can differ from the source you typed.

Sources and browser support

MDN: body describes the syntax and links to the specification and compatibility data. Check individual values in that table when supporting older browsers.