HTML Body

The Body

The HTML body element will define the rest of the HTML page which is the bulk of your document. It will include headers, paragraphs, lists, tables, and more. These elements are described fully in the rest of this document.

An example body section:

<body text="#000000" bgcolor="#FFFFFF" link="#0000FF"
   vlink="#000080" alink="#FF0000">
<h1 style="text-align: center">HTML Document Structure</h1>
<p>
This is a sample HTML file.
</p>
</body>
</html>

The above example is similar to the body section in the example in the "HTML Document Structure" section with the exception that this example controls the body background, wallpaper, and link color directly rather than using style sheets. As you can see below many of the attributes to control the BODY are depreciated in favor of style sheet use.


The BODY Element Tags and Attributes

The <body> tag is used to start the BODY element and the </body> tag ends it. It is used to divide a web page within one or more sections. Its tags and attributes are:

  • <body> - Designates the start of the body.
    • ONLOAD - Used to specify the name of a script to run when the document is loaded.
    • ONUNLOAD - Used to specify the name of a script to run when the document exits.
    • BACKGROUND="clouds.gif" - (Depreciated) Defines the name of a file to use for the background for the page. The background can be specified as in the following line.

      <body text="#000000" bgcolor="#FFFFFF" link="#0000EF" vlink="#51188E" alink="#FF0000" background="clouds.gif">

    • BGCOLOR="white" - (Depreciated) Designates the page background color.
    • TEXT="black" - (Depreciated) Designates the color of the page's text.
    • LINK="blue" - (Depreciated) Designates the color of links that have not been visited.
    • ALINK="red" - (Depreciated) Designates the color of the link currently being visited.
    • VliNK="green" - (Depreciated) Designates the color of visited links.
  • </body> - Designates the end of the body.



For the depreciated attributes noted above, see the "Setting document style" section for an example of how to set the same attributes using a style sheet. If the colors are defined with "#FFFFFF" as done in the above example, the values indicate the intensity of the colors, red, green, and blue in hexadecimal. The leftmost two "FF" indicate the strength of the color red, the center indicates the strength of the color green, and the rightmost two indicate the strength of the color blue. The values may be a hexadecimal value from 0 through FF which in decimal is 0 through 255. The highest value being the highest strength of the respective color. This format is "RRGGBB". You can also specify the color with one of the following standard colors.

  1. black
  2. white
  3. red
  4. green
  5. blue
  6. yellow
  7. magenta or fuschia
  8. cyan or aqua
  9. purple
  10. gray
  11. lime
  12. maroon
  13. navy
  14. olive
  15. silver
  16. teal

Setting a background image on the page

To set up a background on the web page use a BODY statement with the BACKGROUND attribute defined as follows:

<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#000080" alink="#FF0000" background="clouds.gif">

This method is depreciated and authors are encouraged to use style sheets.