<BODY>NN all   IE all   HTML all
<BODY>...</BODY>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 when browsers 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 Navigator and Internet Explorer for years to come.

The BODY element is also where window object event handlers 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 entirely true. The document object has additional properties (such as the document.title) that are defined outside of the BODY element in an HTML document. Also, most browsers don't quibble when you omit either or both the start and end tags. But if you are debugging a page, it's helpful to see the end tags for the BODY and HTML elements when viewing the source to verify that the page has fully loaded into the browser.

 
Example
<BODY BACKGROUND="watermark.jpg" onLoad="init()">
...
</BODY>
 
Object Model Reference
NN [window.]document
IE [window.]document.body
BACKGROUNDNN 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.

This attribute is deprecated in HTML 4.0 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
IE [window.]document.body.background
BGCOLORNN 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.0 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
NN [window.]document.bgColor
IE [window.]document.bgColor
[window.]document.body.bgColor
BGPROPERTIESNN 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
IE [window.]document.body.bgProperties
BOTTOMMARGINNN 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 4, 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
IE [window.]document.body.bottomMargin
LEFTMARGINNN n/a   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 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 (Windows); 8 (Macintosh).
 
Object Model Reference
IE [window.]document.body.leftMargin
RIGHTMARGINNN 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 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
IE [window.]document.body.rightMargin
SCROLLNN n/a   IE 4   HTML
SCROLL=yes | noOptional
 

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 4 for the Mac always shows scrollbars when the document is too large for the window, even when the SCROLL attribute is set to no.

 
Example
<BODY SCROLL=NO>...</BODY>
 
Value
Constant values yes or no (case insensitive).
 
Default yes
 
Object Model Reference
IE [window.]document.body.scroll
TEXTNN 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 rule.

 
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
NN [window.]document.fgColor
IE [window.]document.fgColor
[window.]document.body.text
TOPMARGINNN n/a   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 element hierarchy, this attribute setting fixes the top margin context for all nested elements in the document. On both Windows and Macintosh versions, 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 (Windows); 8 (Macintosh).
 
Object Model Reference
IE [window.]document.body.topMargin
Hosted by uCoz