Little Web Hut

HTML 4.01 and XHTML 1.0 Reference: <body> Tag

HTML <body> Tag - Document Content
Syntax This element uses separate opening and closing tags.
<body>...</body>
Usage The <body> tag is used to contain the content of the web page document that will be displayed. There are 2 main sections in a web page, the head section and the body section. The head section contains information about the web page like the title, style sheet info, scripts etc. The body section contains the content that will be displayed.

HTML & XHTML <body> example.
<body>
 <p>This text is contained in the body section.</p>
</body>
Test It HTML StyleTest It XHTML Style

Content Model The <body> element can contain the following tags, and Text, between its opening and closing tags when using DTD Transitional and Frameset documents.
The <body> element can contain the following tags between its opening and closing tags when using DTD Strict documents.Notes:
1. The <body> element can contain the <noframes> tag when using DTD Transitional documents but not Strict or Frameset documents.
2. Red tags have been deprecated and are allowed in DTD Transitional and Frameset documents but not Strict documents.

Red attributes have been deprecated
<body> Tag Attribute Summary
Required Tag Specific Core Focus Events Language
  alink background bgcolor link onload onunload text vlink id class style title   onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup dir lang xml:lang1
Notes: 1. XHTML only.

Red attributes have been deprecated
<body> Tag Attributes
Attribute Description
alinkThe alink attribute specifies the color of active links. Links are typically considered active while the mouse button is being depressed over the link. The color value can be expressed as an sRGB value which is a hash (#) symbol followed by a hexadecimal value. Or, the color value can be expressed as a color name. Color names are black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, or aqua.

HTML & XHTML <body> tag example using the alink attribute.
<body alink="#336633">
 <p>The following link will turn to the alink color while the mouse
  button is being depressed over the link</p>
 <p>
 <a href="http://www.littlewebhut.com">Little Web hut</a>
 </p>
</body>
Test It HTML StyleTest It XHTML Style


Note: This attribute has been deprecated.
backgroundThe background attribute specifies the URL of a background image. If the image is smaller than the viewable area then the image is typically tiled.

HTML & XHTML <body> tag example using the background attribute.
<body background="shapes.gif">
 <h1>Tiled background</h1>
</body>
Test It HTML StyleTest It XHTML Style


Note: This attribute has been deprecated.
bgcolorThe bgcolor attribute specifies the color of the web page background. The color value can be expressed as an sRGB value which is a hash (#) symbol followed by a hexadecimal value. Or, the color value can be expressed as a color name. Color names are black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, or aqua.

HTML & XHTML <body> example using the bgcolor attribute with an sRGB color value.
<body bgcolor="#FFFF00">
 <h1>This is a yellow colored background using a color value of #FFFF00.</h1>
</body>
Test It HTML StyleTest It XHTML Style

HTML & XHTML <body> example using the bgcolor attribute with a color name value.
<body bgcolor="yellow">
 <h1>This is a yellow colored background</h1>
</body>
Test It HTML StyleTest It XHTML Style


Note: This attribute has been deprecated.
linkThe link attribute specifies the color for the unvisited links in the web page.
The color value can be expressed as an sRGB value which is a hash (#) symbol followed by a hexadecimal value. Or, the color value can be expressed as a color name. Color names are black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, or aqua.

HTML & XHTML <body> tag example using the link attribute.
<body link="#FF6600">
 <p>The following link will be the specified color if the link has not yet been visited.</p>
 <p>
 <a href="example_body_link.html">Test Link</a>
 </p>
</body>
Test It HTML StyleTest It XHTML Style


Note: This attribute has been deprecated.
onloadThe onload attribute is used to specify a script to be be run when the web page has been loaded.
onunloadThe onunload attribute is used to specify a script to be be run when the web page has been removed.
textThe text attribute specifies the default color for text that are not links. The color value can be expressed as an sRGB value which is a hash (#) symbol followed by a hexadecimal value. Or, the color value can be expressed as a color name. Color names are black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, or aqua.

HTML & XHTML <body> tag example using the text attribute.
<body text="red">
 <p>The text, which is not a link, will be displayed as red.</p>
 <p>
 <a href="http://www.littlewebhut.com">This is link text</a>
 </p>
</body>
Test It HTML StyleTest It XHTML Style


Note: This attribute has been deprecated.
vlinkThe vlink attribute specifies the color for links that have already been visited. The color value can be expressed as an sRGB value which is a hash (#) symbol followed by a hexadecimal value. Or, the color value can be expressed as a color name. Color names are black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, or aqua.

HTML & XHTML <body> tag example using the vlink attribute.
<body vlink="green">
 <p>The following link will be the specified color if the link has already been been visited.</p>
 <p>
 <a href="http://www.littlewebhut.com">Little Web hut</a>
 </p>
</body>
Test It HTML StyleTest It XHTML Style


Note: This attribute has been deprecated.
idThe id attribute assigns a unique name to a tag. This allows style sheets or scripts to reference the tag. See id Example
classThe class attribute assigns a class name to a tag. The class name does not need to be unique. More than one tag can have the same class name. This allows style sheets or scripts to reference multiple tags with a single class name. See class Example
styleThe style attribute specifies styles for the tag. For Cascading Style Sheets (CSS), the syntax is name:value. Each name:value pair is separated by semicolons. See style Example
titleThe title attribute specifies additional information about the tag. It is common for browsers to display the title when the pointing device stops over the object. See title Example
onclickThe onclick attribute specifies a script to be run when the object is clicked with a mouse or other pointing device. See onclick Example
ondblclickThe ondblclick attribute specifies a script to be run when the object is double clicked with a mouse or other pointing device. See ondblclick Example
onkeydownThe onkeydown attribute specifies a script to be run when a key is pressed down. See onkeydown Example
onkeypressThe onkeypress attribute specifies a script to be run when a key is pressed and released. See onkeypress Example
onkeyupThe onkeyup attribute specifies a script to be run when a key is released. See onkeyup Example
onmousedownThe onmousedown attribute specifies a script to be run when the mouse button, or other pointing device button, is pressed while over the object. See onmousedown Example
onmousemoveThe onmousemove attribute specifies a script to be run when the mouse, or other pointing device, is moved while it is over the object. See onmousemove Example
onmouseoutThe onmouseout attribute specifies a script to be run when the mouse, or other pointing device, is moved away from an object after being over it. See onmouseout Example
onmouseoverThe onmouseover attribute specifies a script to be run when the mouse, or other pointing device, is moved onto the object. See onmouseover Example
onmouseupThe onmouseup attribute specifies a script to be run when the mouse button, or other pointing device button, is released while over the object. See onmouseup Example
dirThe dir attribute tells the browser whether the text should be displayed from left-to-right or right-to-left. It does not reverse the direction of the characters, like the <bdo> tag does, but it can help the browser to determine if the text should be aligned on the left side or the right side. See dir Example
langThe lang attribute specifies a language. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See lang Example
xml:langThe xml:lang attribute specifies a language for XHTML documents. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See xml:lang Example

Note: XHTML only.

HTML <body> Tag Examples
Test It HTML StyleTest It HTML Style<body> example.
Test It HTML StyleTest It HTML Style<body> tag example using the alink attribute.
Test It HTML StyleTest It HTML Style<body> tag example using the background attribute.
Test It HTML StyleTest It HTML Style<body> example using the bgcolor attribute with an sRGB color value.
Test It HTML StyleTest It HTML Style<body> example using the bgcolor attribute with a color name value.
Test It HTML StyleTest It HTML Style<body> tag example using the link attribute.
Test It HTML StyleTest It HTML Style<body> tag example using the text attribute.
Test It HTML StyleTest It HTML Style<body> tag example using the vlink attribute.