Syntax
<body>
<h1>Visible content goes here</h1>
</body>Examples
Basic Body Content
A body containing typical page content.
<body>
<h1>Welcome</h1>
<p>This is the visible content of the page.</p>
</body>Body with Event Attributes
Attaching a page-load event directly to body (though addEventListener is generally preferred).
<body onload="console.log('Page loaded')">
<p>Content...</p>
</body>Full Document Structure
Seeing body in context alongside head.
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<h1>My Page</h1>
<p>Content visible to the user.</p>
</body>
</html>Best practices
- Only one <body> element is allowed per document
- Keep metadata like <title>, <meta>, and <link> in <head>, not <body>
- Prefer addEventListener in a script over inline event attributes like onload for cleaner separation of concerns
- Everything a user can see or interact with belongs inside <body>
Browser compatibility
Support applies to the named feature, not every attribute or behaviour in this article. Versions refer to browsers, not operating systems.
<body>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
From 1 - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
From 1 - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- From 1
Edge
- From 12
Opera
- From 15
Safari on iOS
- From 1
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
MDN BCD 8.1.5 · Dataset built 2026-10-08 · Mapping reviewed 2026-10-21. These dates are not individual browser-test or claim-verification dates. Unknown means the data does not establish support.