Language References
Represents the main content of the document. | HTML 2, 3.2, 4, 4.01, 5 |
HTML Syntax
<body
alink = color
background = url
bgcolor = color
link = color
text = color
vlink = color
event = script
>
The body of a document contains the document’s content.
The content may be presented by a user agent in a variety of ways. For example, for visual browsers, you can think of the body as a canvas where the content appears: text, images, colors, graphics, etc. For audio user agents, the same content may be spoken.
NOTE: There can only be one <body
> element in a document.
HTML 3.2 included attributes wherein an author can specify characteristics for the <body
>, such as the background color or an image to use as a tiled background, the default text color, and the colors for active, unvisited and visited links.
Since style sheets are now the preferred way to specify a document’s presentation, the presentational attributes of <body
> have been deprecated in favor of CSS styles. Still they are included in this workshop for backward compatibility with downlevel browsers.
The BODY element can be used with script to respond to events.
Actions can be specified to occur when the document finishes loading ( onload ) or is unloaded ( onunload ), and when the window in which the document is displayed receives ( onfocus ) or loses focus ( onblur ).
In script, the BODY element is accessed using the body property on the document object.
NOTE: Both start and end tags are ommissible, in certain situations.
The <body
> element supports the following attributes, in addition to global attributes common to all HTML elements.
Attribute | Value | Description |
alink | color | Specifies the color of active link (while the mouse button is held down during a click) in a document. |
background | URL | Specifies a background image for the document. |
bgcolor | color | Specifies the background color of the document. |
link | color | Specifies the color of unvisited links in a document. |
text | color | Specifies the foreground color for text in a document. |
vlink | color | Specifies the color of visited links (links that have already been followed) in a document. |
<html>
<head>
<title>Sample HTML document</title>
</head>
<body>
<p>Hello, World.</p>
</body>
</html>
Show me
HTML HEAD FRAMESET