DOM Properties
Document.body
References the body (or legacy frameset) and may be null early in parsing. Assigning a replacement body replaces the old one; prefer targeted DOM updates. Example result: body.
Formal Syntax & Structure
html syntaxhtml
document.bodyReturn Value
HTMLElement | null
Current document value.
Working Example
Example Snippethtml
<p> Result: <output id="result"></output></p><script> const result = document.getElementById("result"); (async () => { result.textContent = document.body.localName; })().catch(error => { result.textContent = "Error: " + error.name; });</script>