html5 Site Icon CSS3 Site Icon CSS Site Icon

HTML4 Reference

HTML <body> tag

Definition

The <body> tag and it's closing </body> tag defines the document body of a HTML file.

Example


<html  xmlns="http://www.w3.org/1999/xhtml">
Everything goes between the start and end HTML tags. 

<head>
  The header contains meta information pertaining to the HTML document as well 
  as a mandatory title tag. External files such as CSS stylesheets and JavaScript
  files are also imported in the header section of our HTML file.
  <title>Appears in browser toolbar, favourites and search engine results.</title>
</head>

<body>
  The content of the web page appears in the body section.
</body>

We complete the HTML file with the closing HTML tag.
</html>

Required Attributes

NONE

Optional Attributes

alink - this attribute is deprecated, use CSS instead.

background - this attribute is deprecated, use CSS instead.

bgcolor - this attribute is deprecated, use CSS instead.

link - this attribute is deprecated, use CSS instead.

text - this attribute is deprecated, use CSS instead.

vlink - this attribute is deprecated, use CSS instead.

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<body class="classname"></body>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<body id="idname"></body>

style - specifies an inline style for the element allowing you to apply the style to the content.


<body style="color:red;text-align:left"></body>

title - specifies extra information about the content.


<body title="information about the content"></body>

Language Attributes

dir - specifies the directional flow of the content.


<body dir="ltr"></body>   <!-- The text will flow from left to right -->

<body dir="rtl"></body>   <!-- The text will flow from right to left -->

lang - specifies a language code for the content of the element.


<body lang="en"></body>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<body xml:lang="fr"><body>

Document Event Attributes

onload - The JavaScript code to be run when the document is loaded.


<body onload="go()"></body>   <!-- Executes the go() function -->

onunload - The JavaScript code to be run when the document is unloaded.


<body onunload="go()"></body>   <!-- Executes the go() function -->

Form Event Attributes

NONE

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<body onkeydown="go()"></body>   <!-- Executes the go() function -->

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<body onkeypress="go()"></body>   <!-- Executes the go() function -->

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<body onkeyup="go()"></body>   <!-- Executes the go() function -->

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<body onclick="go()"></body>   <!-- Executes the go() function -->

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<body ondblclick="go()"></body>   <!-- Executes the go() function -->

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<body onmousedown="go()"></body>   <!-- Executes the go() function -->

onmousemove - The JavaScript code to be run when the mouse button is moved.


<body onmousemove="go()"></body>   <!-- Executes the go() function -->

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<body onmouseout="go()"></body>   <!-- Executes the go() function -->

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<body onmouseover="go()"></body>   <!-- Executes the go() function -->

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<body onmouseup="go()"></body>   <!-- Executes the go() function -->


<blockquote> tag    << Prev          Next >>  <br /> tag

go to home page Homepage go to top of page Top

HTML Elements

The complete set of HTML elements also known as HTML tags from the latest HTML 4.01 Specification.

Click the links for more information on individual tags and their attributes.

<!--...-->

<!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> - <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>