asp.net.ph

Skip Navigation Links

BODY Element | body Object

Language References


Represents the main content of the document.HTML 2, 3.2, 4, 4.01, 5

HTML Syntax

Remarks

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.

Attributes

The <body> element supports the following attributes, in addition to global attributes common to all HTML elements.

AttributeValueDescription
alinkcolorSpecifies the color of active link (while the mouse button is held down during a click) in a document.
backgroundURLSpecifies a background image for the document.
bgcolorcolorSpecifies the background color of the document.
linkcolorSpecifies the color of unvisited links in a document.
textcolorSpecifies the foreground color for text in a document.
vlinkcolorSpecifies the color of visited links (links that have already been followed) in a document.

Example

<html>
<head>
   <title>Sample HTML document</title>
</head>
<body>
   <p>Hello, World.</p>
</body>
</html>

 Show me 

See Also

HTML   HEAD   FRAMESET



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note