body Element


 

Module

The body element is declared by the XHTML 1.1 Structure Module

Elements in the Structure Module are:
html | head | title | body

Description

The body element is the container for all the visible content on the page and comes immediately after the head element. The world is pretty much your oyster with this one, just remember that only block level elements (and comments, scripting and whitespace) may be children of body. All inline elements and #PCDATA must have a containing block level element. See the Content Model for a list of allowable children.

The example below shows a very simple body element. Note that the image cannot validly be placed as a child of body but must be enclosed within a block level element, in this case div. Remember to enclose your body element within the correct html element structure.

<body>
  <h1>My Interesting Page about Hippos</h1>
  <div class="intro">
    <p>Hippo is short for hippopotamus which means 'river horse' in Greek.
       In Latin, I therefore believe the hippo would be called "Equus Fluminis".</p>
    <p>The hippo is an artiodactyl ungulate and the common hippo has
       the binomial name (Genus and Species) of "Hippopotamus amphibius".</p>
  </div>
  <div class="image">
    <img src="hippo.jpg" width="400" height="300" alt="[Image: A Hippo with its calves]" />
  </div>
</body>

#REQUIRED Attributes

There are no #REQUIRED attributes on the body element.


Specific Attributes

From the Intrinsic Events Module

onload [ type Script ]
Script to be executed immediately after the document has finished loading
onunload [ type Script ]
Script to be executed on leaving the page

Common Attributes

Common attributes of the body element are listed below:

From the Core Attribute Collection

class [ type NMTOKENS ]
One or more space separated classes
id [ type ID ]
A unique identifier for the element
style [ type CDATA ], from the Style Attribute Module (deprecated)
Element-specific styles
title [ type Text ]
Descriptive title for the element (in some user agents this may appear as a "tooltip" when the mouse hovers over the element)
xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

From the Events Attribute Collection

All attributes in the Events Attribute Collection are supported:
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Content Model

The Content Model for the body element is:

Block.mix*

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of body

Valid parents of body


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > body Element