<body> ... </body>is used to define the main body element of an HTML document as distinct from the <head> element.
Text etc., contained within the <body> ... </body> tags will be displayed in the main browser window.
Many browsers support a number of attributes for this tag. The commonest are
The value of this attribute is a colour that is to be used as the background colour of the displayed text in preference to whatever default happens to be in operation. Its careful use can considerably enhance the appearance of text however it must be considered in connection with the text colours.
The value of this attribute is the URL of an image to be used as background for the displayed text. The image is displayed as many times as necessary to "tile" the display. This should be used with caution, it is very easy to set up a background image that is distracting and can make the text unreadable. The usual cautions about the use of images apply.
Here's an example
Normally the background image and the text scroll in step.
This non-HTML 3.2 attribute is only understood by Microsoft Internet Explorer. It controls the scrolling of the background image. The attribute has two possible values fixed and scroll. The value fixed causes the text to scroll over a fixed background whereas scroll causes the text and background to scroll in step. Here, for Microsoft Internet Explorer users, is an example of a fixed background, compare it with the normal behaviour.
You may have to resize your browser window to see the effect.
The value of this attribute is a colour that is to be used as the normal text colour in preference to the browser default (usually black). It should be selected for good contrast with the background and the link colours.
The value of this attribute is a colour that is to be used as the normal colour for text that is included within an <a> element with an href attribute. I.e. "hot" text. Many browsers use a default colour of blue.
There is no way of controlling the practice of many browsers of presenting such text underlined but authors should be aware that many browser users turn off underlining so link text should be made a distinctive colour.
The value of this attribute is a colour that is to be used for text that represents a link that has already been visited. Many browsers use a default colour of purple.
The value of this attribute is a colour that is to be used for "active" links, I.e. links that are currently being processed by the browser. Red is a common browser default. It will, normally, only be seen fleetingly.
This non-HTML 3.2 attribute is only understood by Microsoft Internet Explorer. It specifies a vertical margin, in pixels, at the top and bottom of the text between the text and the browser window. Here's an example with the value set to 100.
This non-HTML 3.2 attribute is only understood by Microsoft Internet Explorer. It specifies a horizontal margin, in pixels, at the left and right of the text between the text and the browser window. Here's an example with the value set to 75.
Here is a link to a page with the following attributes set to the indicated values
Attribute | value |
---|---|
bgcolor | ff0000 (red) |
text | 0000ff (blue) |
link | 00ff00 (green) |
vlink | 000000 (black) |
It is not claimed that this is a wise choice of colours. In particular, the use of blue for anything other than a link is confusing as most people are used to seeing blue used for links.
The colour settings associated with the <body> tag apply to the complete page, there is no way of applying them to a single paragraph.
If none of the colour setting attributes are set, text will be rendered using the browser defaults, these are entirely under the control of the user and are, thus, unpredictable. If any of the colours are set explicitly, they should all be set explicitly to avoid possible clashes between explicitly set colours and browser defaults.
See also <head>