HTMLforall

  HTML | PHP | Forum

HTML <body> tag

Syntax

<body> - </body>

Definition and Usage

The body element contains the documents' body, like text, images, colors, graphics, ...

The <body> tagis required in non-frames documents, but its start and end tags are always optional.

Optional Attributes

Attribute Value Description
alink rgb(x,x,x), #rrggbb or colorname Specify the color of the active links in the document. Deprecated. Use styles instead.
background file_name An image file to be used as the background. Deprecated. Use styles instead.
bgcolor rgb(x,x,x), #rrggbb or colorname The background color of the document. Deprecated. Use styles instead.
link rgb(x,x,x), #rrggbb or colorname Specify the color of all the links in the document. Deprecated. Use styles instead.
text rgb(x,x,x), #rrggbb or colorname Specify the color of the text in the document. Deprecated. Use styles instead.
vlink rgb(x,x,x), #rrggbb or colorname Specify the color of the visited links in the document. Deprecated. Use styles instead.

Standard Attributes

id, class, title, style, dir, lang, xml:lang

For a full description, go to Standard Attributes.

Event Attributes

onload, onunload, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to Event Attributes.

Example

Source Output
Deprecated example
<HTML>
<HEAD>
 <TITLE>This is a test document</TITLE>
</HEAD>
<BODY bgcolor="white" text="black"
  link="red" alink="fuchsia" vlink="maroon">
  ... document body...
</BODY>
</HTML>

Using style sheets, the same effect could be accomplished as follows:

<HTML>
<HEAD>
 <TITLE>This is a test document</TITLE>
 <STYLE type="text/css">
  BODY { background: white; color: black}
  A:link { color: red }
  A:visited { color: maroon }
  A:active { color: fuchsia }
 </STYLE>
</HEAD>
<BODY>
  ... document body...
</BODY>
</HTML>

Using external (linked) style sheets gives you the flexibility to change the presentation without revising the source HTML document:

<HTML>
<HEAD>
 <TITLE>This is a test document</TITLE>
 <LINK rel="stylesheet" type="text/css" href="smartstyle.css">
</HEAD>
<BODY>
  ... document body...
</BODY>
</HTML>

 

N/A

Home

Learn HTML
HTML Tutorial

HTML Reference
HTML by function
HTML by Alphabet

HTML events
HTML attributes
HTML color names

<!--...-->
<!DOCTYPE> 
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<b>
<base>
<basefont>
<bdo>
<big>
<blockquote>
<body>
<br>
<button>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<dd>
<del>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<fieldset>
<font>
<form>
<frame>
<frameset>
<h1> to <h6>
<head>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<isindex>
<kbd>
<label>
<legend>
<li>
<link>
<map>
<menu>
<meta>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<p>
<param>
<pre>
<q>
<s>
<samp>
<script>
<select>
<small>
<span>
<strike>
<strong>
<style>
<sub>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<title>
<tr>
<tt>
<u>
<ul>
<var>

 

Copyright 2005-8 Sunilcare.  All Rights Reserved.
Comments or suggestions? Contact us.About us