# HTML DOM body property
[ Document Object](#)
## Example
Change the background color of the current document:
document.body.style.backgroundColor = "yellow";
[Try it Β»](#)
* * *
## Definition and Usage
The body property is used to set or return the document body.
**If used to return**, this property returns the current document's **** element.
**If used to set**, this property will override all child elements within the element and replace them with new content.
**Note:** Unlike the [document.documentElement](#) property, the document.body property returns the element, while the document.documentElement property returns the element.
* * *
## Browser Support
| Property | | | | | |
| --- | --- | --- | --- | --- | --- |
| body | Yes | Yes | Yes | Yes | Yes |
* * *
## Syntax
To get the body property:
document.body
To set the body property:
document.body = newContent
## Property Values
| Value | Description |
| --- | --- |
| _newContent_ | Specifies the new content for the element |
## Technical Details
| DOM Version: | Core Level 1 Document Object |
| --- |
| Return Value: | A reference to the Body object, representing the element |
* * *
## More Examples
## Example
Get the HTML content of the current document:
var x = document.body.innerHTML;
[Try it Β»](#)
## Example
Change the HTML content of the current document:
document.body.innerHTML = "New content...";
[Try it Β»](#)
## Example
Create a
element and add it to the document:
var x = document.createElement("P"); // Create a
element
var t = document.createTextNode("This is a new paragraph."); // Create a text node
x.appendChild(t); // Append the text to the
element
document.body.appendChild(x); // Append the
to the
[Try it Β»](#)
* * *
## Related Pages
HTML Reference: (#)
JavaScript Reference: (#)
[ Document Object](#)