ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
Last Update: 25 September 2000

4. BODY

The BODY element contains all the content of a document, as opposed to the HEAD, which contains information about the document. Various mark-up elements are allowed within the body to indicate headings, paragraphs, lists, hypertext links, images, and so on. These are described and illustrated in documents following this one.

The following shows typical use of HEAD and BODY elements, using this document as an example:

<HTML>
<HEAD>
<TITLE> BODY element in HTML </TITLE>
<BASE HREF="http://www.utoronto.ca/webdocs/HTMLdocs/NewHTML/body.html">
</HEAD>

<BODY>
[<a href="htmlindex.html">ToC</a>]
[<a href="htmlindex.html">Up</a>]

<H1> BODY Element in HTML </H1>

<p> The BODY element contains all the content of the document,
as opposed to the <a href="head.html">HEAD</a>, which 
contains information about the document.  </p>......
</BODY>
</HTML>

4.0.1 The BACKGROUND Attribute

In HTML 2.0, the BODY element had no attributes. Netscape 1.1 introduces the single attribute BACKGROUND. This allows you to specify an image file to use as a background (a bit like a watermark) behind the displayed text and graphics.

The following example (please read the following text and then follow the example link)

 <BODY BACKGROUND="back/marble.gif">
 <h1> Bla Bla Bla </h1>
 <p> And still more text....
 </BODY>

tiles the window background with the designated GIF image. Just click on the anchor to look at the example.

4.0.2 HTML 3.2 Extensions

Setting a background color is not enough -- for example, if you set the background to black, you need to be able to change the color of the text as well. Netscape introduced several new attributes for controlling the text color. These are described below, and became, as of HTML 3.2, part of the HTML standard. There is also an example document illustrating these BODY attributes.

BGCOLOR="#rrggbb"
Sets the background color to the specified RGB color value, where RR GG and BB are the hexadecimal color codes for the Red, Green and Blue levels, ranging from 0 to 255 -- that is, 00 to FF. The color "000000" is black, while "FFFFFF" is white. If there is also a background image, the BGCOLOR is used as the color underneath the background image -- if the background image is transparent, this is the color that shows through.
TEXT="#rrggbb"
Sets the default text color to the specified RGB color value.
LINK="#rrggbb"
Sets the default text color of hypertext anchors to the specified RGB color value.
VLINK="#rrggbb"
Sets the default text color of visited hypertext links to the specified RGB color value.

Most browsers also support special color names (white, blue, etc.). A list of the allowed colors is found at the supporting Web site for my HTML book, at: http://www.utoronto.ca/ian/books/html4ed/appf/color1.html.

4.0.3 Netscape 4 /Internet Explorer 4 Extensions

These browsers added attributes that set the padding around the text the page -- essentially setting the page margins. Of course, the two companies selected different names for these attributes. These properties are:

LEFTMARGIN="nn" (Navigator 4) and MARGINWIDTH="nn" (Internet Explorer 4/5)
Sets the page margin on the left (and right for Internet Explorer) of the page to be of size nn pixels.
TOPMARGIN="nn" (Naviagator 4) and MARGINHEIGHT="nn" (Internet Explorer 4/5)
Sets the page margin at the top of the page to be of size nn pixels.


ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
© 1994-1998 by Ian Graham
Last Update: 25 September 2000