Skip to: content, navigation

by Ian Lloyd

body (HTML element)

Spec
Depr. Empty Version
No No HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full

Example

The body contains all the content that’s to be made visible to the user:

<body>
  <h1>101 Ways to make a paper aeroplane</h1>
  <p>Let's start with the basics …</p>
  ⋮
</body>
Type
structural element
Contains
all elements (except base, style, frameset, frame, meta, link)
Contained by
html

Description

The body element wraps around all of the content that will be displayed on screen (or in other media, such as print), such as headings, paragraphs, images, tables, and so on. It has some unique attributes, including alink, link, and vlink, all of which are now deprecated, as well as a number of other attributes that aren’t defined in any standard but are, regrettably, still in common use. These are:

  • marginheight

    sets the space between the top and bottom of the document content and the viewport (originally defined by Netscape 4)

  • marginwidth

    sets the space between the left and right of the document content and the viewport (originally defined by Netscape 4)

  • topmargin/bottommargin

    Internet Explorer’s equivalent of marginheight (allows us to set top and bottom margins separately)

  • leftmargin/rightmargin

    Internet Explorer’s equivalent of marginwidth (allows the setting of left and right margins separately)

Note that these attributes are no longer required to achieve the visual effects they were originally intended for—the equivalent CSS for these attributes is the margin property (or margin-top, margin-right, and so on), which is supported by all browsers.

All web pages require a body element, with the exception of frameset-based web pages, for which the appropriate frameset doctype must be declared.

Use This For …

Use body to hold all the document content that you want to be visible to the reader.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Every browser listed supports this element type.

In this Section

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters