body element | body object
[This documentation is preliminary and is subject to change.]
Specifies the beginning and end of the document body.
![]() ![]() |
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5
- HTML 4.01 Specification, Section 7.5.1
HTML information
| Closing Tag | required |
|---|---|
| CSS Display | block |
DOM Information
Inheritance Hierarchy
Remarks
You can access the body element from script through the document object.
The window object for the body element can host event handlers for the onblur, onfocus, onload, or onunload events.
Windows Internet Explorer 8 and later. The value of the background attribute depends on the current document compatibility mode.
As of Microsoft Internet Explorer 6, when you use the !DOCTYPE declaration to specify standards-compliant mode, the body object can obtain its size from its content, or you can set its size explicitly—like a div object, for example. In standards-compliant mode, the html element represents the entire surface onto which a document's contents can be rendered. When the !DOCTYPE declaration does not specify standards-compliant mode, and with earlier versions of Windows Internet Explorer, the body object represents the entire surface onto which a document's contents can be rendered. The size of the body object cannot be changed and is equal to the size of the window. Margins you set on this object are rendered inside the border and scrollbars of the object.
In Internet Explorer 6, When you use the !DOCTYPE declaration to specify standards-compliant mode, this object no longer represents the entire surface onto which a document's contents can be rendered. The object can obtain its size from its content, or you can set its size explicitly like a div object.
Examples
This example exposes the body element in script.
var oBody = document.body;
See also
- CSS Enhancements in Internet Explorer 6
Build date: 3/8/2012

