<BODY> | NN all IE all HTML all
<BODY>...</BODY> | HTML End Tag: Optional
After all of the prefatory material in the head portion of an HTML file, the body element contains the genuine content of the page that the user sees in the browser window (or may hear from browsers that know how to speak to users). Before style sheets, the body element was the place where page authors could specify document-wide color and background schemes. A great many favorite attributes covering these properties are deprecated in HTML 4, in favor of style sheet rules that may be applied to the body element. Support for all these attributes, however, will remain in mainstream browsers for years to come.

The body element is also where window object event handler attributes are placed. For example, a window object as defined in most document object models has an onload event handler that fires when a document has finished loading into the current window or frame. Assigning that event handler as an element attribute is done in the body element.

Although it may appear from a variety of implications that the body element is the document object, this is not true. The document object has additional properties (such as the document.title) that are defined outside of the body element in an HTML document. In a W3C-DOM-aware browser, the document node tree puts more distance between the root document node and the body element: the document node is the parent of the html element; the html element is the parent of both the head and body elements.

Example
    <BODY background="watermark.jpg" onLoad="init( );">
    ...
    </BODY>
Object Model Reference
    [window.]document.body
Element-Specific Attributes

alink | background | bgcolor | bgproperties | bottommargin
leftmargin | link | marginheight | marginwidth | nowrap
rightmargin | scroll | text | topmargin | vlink

Element-Specific Event Handler Attributes

Handler | NN | IE | HTML
onafterprint | n/a | 5 | n/a
onbeforeprint | n/a | 5 | n/a
onload | 2 | 3 | 4
onresize | 4 | 4 | n/a
onscroll | n/a | 4 | n/a
onselect | n/a | 4 | n/a
onunload | 2 | 3 | 4

alink | NN all IE all HTML 3.2
alink="colorTripletOrName" | Optional
Establishes the color of a hypertext link when it is activated (being clicked on) by the user. This is one of three states for a link: unvisited, active, and visited. The color is applied to the link text or border around an image or object embedded within an a element. This attribute is deprecated in favor of the CSS :active pseudo-class style rule for an a element, as described in Chapter 11.
Example
    <BODY alink="#FF0000">...</BODY>
Value
A hexadecimal triplet or plain-language color name. See Appendix A for acceptable plain-language color names.
Default
#FF0000 (typically).
Object Model Reference
    [window.]document.alinkColor
    [window.]document.body.aLink

background | NN all IE all HTML 3.2
background="URL" | Optional
Specifies an image file that is used as a backdrop to the text and other content of the page. Unlike normal images that get loaded into browser content, a background image loads in its original size (without scaling) and tiles to fill the available document space in the browser window or frame. Smaller images usually download faster but are obviously repeated more often in the background. Animated GIFs are also allowable but very distracting to the reader. When selecting a background image, be sure it is very muted in comparison to the main content so that the content stands out clearly. Background images, if used at all, should be extremely subtle or occupy space free of other content.

This attribute is deprecated in HTML 4 in favor of the background style attribute.

Example
    <BODY background="watermark.jpg">...</BODY>
Value
Any valid URL to an image file, including complete and relative URLs.
Default
None.
Object Model Reference
    [window.]document.body.background

bgcolor | NN all IE all HTML 3.2
bgcolor="colorTripletOrName" | Optional
Establishes a fill color (behind the text and other content) for the entire document. If you combine a bgcolor and background, any transparent areas of the background image let the background color show through. This attribute is deprecated in HTML 4 in favor of the background-color style attribute.
Example
    <BODY bgcolor="tan">...</BODY>
Value
A hexadecimal triplet or plain-language color name. A setting of empty is interpreted as "#000000" (black). See Appendix A for acceptable plain-language color names.
Default
Varies with browser, browser version, and operating system.
Object Model Reference
    [window.]document.bgColor
    [window.]document.body.bgColor

bgproperties | NN n/a IE 3 HTML n/a
bgproperties="property" | Optional
An Internet Explorer attribute that lets you define whether the background image (set with the background attribute or style sheet) remains in a fixed position or scrolls as a user scrolls the page. This can provide both intriguing and odd effects for the user. When the background image is set to remain in a fixed position, scrolled content flows past the background image very much like film credits roll past a background image on the screen.
Example
    <BODY background="watermark.jpg" bgproperties="fixed">...</BODY>
Value
If set to "fixed", the image does not scroll. Omit the attribute or set it to an empty string ("") to let the image scroll with the content.
Default
None.
Object Model Reference
    [window.]document.body.bgProperties

bottommargin | NN n/a IE 4 HTML n/a
bottommargin="integer" | Optional
Establishes the amount of blank space between the very end of the content and the bottom of a scrollable page. The setting has no visual effect if the length of the content or size of the window does not cause the window to scroll. The default value is for the end of the content to be flush with the end of the document, but in the Macintosh version of Internet Explorer, there is about a 10-pixel margin visible even when the attribute is set to zero. Larger sizes are reflected properly. This attribute offers somewhat of a shortcut to setting the margin-bottom style sheet attribute for the body element.
Example
    <BODY bottommargin="20">...</BODY>
Value
A string value of the number of pixels of clear space at the bottom of the document. A value of an empty string is the same as zero.
Default
0
Object Model Reference
    [window.]document.body.bottomMargin

lang | NN 3 IE 4 HTML 4
lang="languageCode" | Optional
The language being used for the element's attribute values and content. A browser can use this information to assist in proper rendering of content with respect to details such as treatment of ligatures (when supported by a particular font or required by a written language), quotation marks, and hyphenation. Other applications and search engines might use this information to aid the selection of spell-checking dictionaries and the creation of indices.
Example
    <SPAN lang="de">Deutsche Bundesbahn</SPAN>
Value
Case-insensitive language code.
Default
Browser default.
Object Model Reference
    [window.]document.getElementById(elementID).lang

leftmargin | NN 6 IE 3 HTML n/a
leftmargin="integer" | Optional
Establishes the amount of blank space between the left edge of the content area of a window and the left edge of the content. This attribute offers somewhat of a shortcut to setting the margin-left style sheet attribute for the body element. As the outermost parent container in the renderable element hierarchy, this attribute setting fixes the left margin context for all nested elements in the document.
Example
    <BODY leftmargin="25">...</BODY>
Value
A string value of the number of pixels of clear space at the left margin of the document. A value of an empty string is the same as zero.
Default
10 (IE/Windows); 8 (IE/Macintosh).
Object Model Reference
    [window.]document.body.leftMargin

link | NN all IE all HTML 3.2
link="colorTripletOrName" | Optional
Establishes the color of a hypertext link that has not been visited (i.e., the URL of the link is not in the browser's cache). This is one of three states for a link: unvisited, active, and visited. The color is applied to the link text or border around an image or object embedded within an a element. This attribute is deprecated in favor of the :link pseudo-class style rule for an a element, as described in Chapter 11).
Example
    <BODY link="#00FF00">...</BODY>
Value
A hexadecimal triplet or plain-language color name. See Appendix A for acceptable plain-language color names.
Default
#0000FF
Object Model Reference
    [window.]document.linkColor
    [window.]document.body.link

marginheight, marginwidth | NN 4 IE n/a HTML n/a
marginheight="integer"marginwidth="integer" | Optional
Shortcut attributes to set the body's margins in lieu of CSS style sheets. Setting marginheight to a pixel value establishes a margin setting above and below the body content; marginwidth sets margins to the left and right of the body.
Example
    <BODY marginheight="20" marginwidth="10">...</BODY>
Value
A string value of the number of pixels of clear space at each of the two sides affected by each attribute. A value of an empty string is the same as zero.
Default
0

nowrap | NN n/a IE 4 HTML n/a
nowrap | Optional
Controls whether wide content should wrap within the body width.
Example
    <BODY nowrap>...</BODY>
Value
The presence of the attribute sets its value to true.
Default
false
Object Model Reference
    [window.]document.body.noWrap

rightmargin | NN n/a IE 4 HTML n/a
rightmargin="integer" | Optional
Establishes the amount of blank space between the right edge of the content area of a window and the right edge of the content. This attribute offers somewhat of a shortcut to setting the margin-right style sheet attribute for the body element. As the outermost parent container in the renderable element hierarchy, this attribute setting fixes the right margin context for all nested elements in the document. Be aware that IE on the Mac does not let content come as close to the right edge of the window as the Windows version.
Example
    <BODY rightmargin="25">... </BODY>
Value
A string value of the number of pixels of clear space at the right margin of the document. A value of an empty string is the same as zero.
Default
10 (Windows); 0 (Macintosh).
Object Model Reference
    [window.]document.body.rightMargin

scroll | NN n/a IE 4 HTML n/a
scroll="featureSwitch" | Optional
Controls the presence of scrollbars when the content space exceeds the size of the current window. Without scrollbars, if you want your users to move around the page, you have to provide some scripted method of adjusting the scroll of the window. Be aware that Internet Explorer for the Mac always shows scrollbars when the document is too large for the window, even when the scroll attribute is set to no. For more modern control over scrollbars, use the overflow CSS attribute (plus IE-specific overflowX and overflowY attributes).
Example
    <BODY scroll="no">...</BODY>
Value
Constant values yes or no (case-insensitive).
Default
yes
Object Model Reference
    [window.]document.body.scroll

text | NN all IE all HTML 3.2
text="colorTripletOrName" | Optional
Establishes the color of body content in the document. Colors of individual elements within the document can override the document-wide setting. Because the default background color of browsers varies widely with browser brand, version, and operating system, it is advisable to set the bgcolor attribute (or equivalent style sheet rule) in concert with the document's text color. This attribute is deprecated in favor of the color style sheet attribute.
Example
    <BODY bgcolor="#FFFFFF" text="#c0c0c0">...</BODY>
Value
A hexadecimal triplet or plain-language color name. See Appendix A for acceptable plain-language color names.
Default
#000000 (black).
Object Model Reference
    [window.]document.fgColor
    [window.]document.body.text

topmargin | NN 6 IE 3 HTML n/a
topmargin="integer" | Optional
Establishes the amount of blank space between the top edge of the content area of a window and the top edge of the content. This attribute offers somewhat of a shortcut to setting the margin-top style sheet attribute for the body element. As the outermost parent container in the renderable element hierarchy, this attribute setting fixes the top margin context for all nested elements in the document. Setting the topmargin attribute to zero or an empty string ("") pushes the content to the very top of the document content region.
Example
    <BODY topmargin="0">... </BODY>
Value
A string value of the number of pixels of clear space at the top of the document. A value of an empty string is the same as zero.
Default
15 (IE/Windows); 8 (IE/Macintosh).
Object Model Reference
    [window.]document.body.topMargin

vlink | NN all IE all HTML 3.2
vlink="colorTripletOrName" | Optional
Establishes the color of a hypertext link after it has been visited by a user (and the destination page is still in the browser's cache). This is one of three states for a link: unvisited, active, and visited. The color is applied to the link text or border around an image or object embedded within an a element. This attribute is deprecated in favor of the :visited pseudo-class style rule for an a element, as described in Chapter 11).
Example
    <BODY vlink="teal">...</BODY>
Value
A hexadecimal triplet or plain-language color name. See Appendix A for acceptable plain-language color names.
Default
#551a8b (NN); #800080 (IE/Windows); #006010 (IE/Macintosh).
Object Model Reference
    [window.]document.vlinkColor
    [window.]document.body.vLink