HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<body> (Document Body)


This element encloses a document's displayable content.

Standard Syntax


<body
alink="color name | #RRGGBB" (transitional)
background="url of background image" (transitional)
bgcolor="color name | #RRGGBB" (transitional)
class="class name(s)"
dir="ltr | rtl"
id="unique alphanumeric identifier"
lang="language code"
link="color name | #RRGGBB" (transitional)
style="style information"
text="color name | #RRGGBB" (transitional)
title="advisory text"
vlink="color name | #RRGGBB" (transitional)
</body>

Attributes Defined by Internet Explorer


accesskey="key" (5.5)
bgproperties="fixed" (4)
bottommargin="pixels" (4)
contenteditable="false | true | inherit" (5.5)
disabled="false | true" (5.5)
hidefocus="true | false" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
leftmargin="pixels" (4)
nowrap="false | true" (4)
rightmargin="pixels" (4)
scroll="no | yes" (4)
tabindex="number" (5.5)
topmargin="pixels" (4)
unselectable="off | on" (5.5)
Attributes Defined by Netscape
marginheight="pixels" (4)
marginwidth="pixels" (4)

Standard Events


onclick, ondblclick, onload, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup, onunload

Events Defined by Internet Explorer


onactivate, onafterprint, onbeforeactivate, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onbeforeprint, onbeforeunload, oncontextmenu, oncontrolselect, oncut, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onfilterchange, onfocusin, onfocusout, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresizeend, onresizestart, onscroll, onselect, onselectstart

Element Specific Attributes


alink
This attribute sets the color for active links within the document. Active links represent the state of a link as it is being pressed. The value of the attribute can be either a browser-dependent named color or a color specified in the hexadecimal #RRGGBB format.

background
This attribute contains a URL for an image file, which will be tiled to provide the document background.

bgcolor
This attribute sets the background color for the document. Its value can be either a browser-dependent named color or a color specified using the hexadecimal #RRGGBB format.

bgproperties
This attribute, first introduced in Internet Explorer 2, has one value, fixed, which causes the background image to act as a fixed watermark and not to scroll.

bottommargin
This attribute specifies the bottom margin for the entire body of the page and overrides the default margin. When set to 0 or "", the bottom margin is the bottom edge of the window or frame the content is displayed in.

leftmargin
This Internet Explorer-specific attribute sets the left margin for the page in pixels, overriding the default margin. When set to 0 or "", the left margin is the left edge of the window or the frame.

link
This attribute sets the color for hyperlinks within the document that have not yet been visited. Its value can be either a browser-dependent named color or a color specified using the hexadecimal #RRGGBB format.

marginheight
This Netscape-specific attribute sets the top margin for the document in pixels. If set to 0 or "", the top margin will be exactly on the top edge of the window or frame. It is equivalent to combining the Internet Explorer attributes bottommargin and topmargin.

marginwidth
This Netscape-specific attribute sets the left and right margins for the page in pixels, overriding the default margin. When set to 0 or "", the left margin is the left edge of the window or the frame. It is equivalent to combining the Internet Explorer attributes leftmargin and rightmargin.

nowrap
This Internet Explorer–specific attribute is used to control the wrapping of text body width. If set to yes, text should not wrap. The default is no. CSS rules should be used instead of this attribute.

rightmargin
This attribute, specific to Internet Explorer, sets the right margin for the page in pixels, overriding the default margin. When set to 0 or "", the right margin is the right edge of the window or the frame.

scroll
This attribute turns the scroll bars on or off. The default value is yes.

text
This attribute sets the text color for the document. Its value can be either a browser-dependent named color or a color specified using the hexadecimal #RRGGBB format.

topmargin
This Internet Explorer-specific attribute sets the top margin for the document in pixels. If set to 0 or "", the top margin will be exactly on the top edge of the window or frame.


Example


<body background="checkered.gif" bgcolor="white" alink="red" link="blue" vlink="red" text="black"> ... </body>

<!-- myLoadFunction defined in document head in <SCRIPT> element -->
<body onload="myLoadFunction()">
... </body>

Compatibility


HTML 2, 3.2, 4, 4.01, and XHTML 1.0, 1.1, Basic
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1, 2, 3, 4- 4.7, 6, 7
Opera 4-7

Notes


When defining text colors, it is important to be careful to specify both foreground and background explicitly so that they are not masked out by browser defaults set by the user.

Under the strict HTMLand XHTMLdefinitions, CSS should be used in place of presentation attributes like alink, background, bgcolor, link, text, and vlink.

This element must be present in all documents except those declaring a frame set.

Under XHTML 1.0, the closing </body> tag is mandatory.

(X)HTML Elements
CSS Properties
Previous: blockquote Next: br
< Home | About | Chapters | Examples | Errata | Reference | Site Map >