The <body> Section

The contents of an HTML document as displayed in a web browser must be placed between the <body> and </body> tags. The only time an HTML document does not have a body element is when it contains frames defined in a frameset. Frames are not discussed on this site. There can be only one body element in an HTML document and it has no non-deprecated attributes other than class which can be used to style the element by referencing a style defined in an external or embedded stylesheet. For example

<body class="corps">

We strongly recommend styling the body element. Most CSS properties, but not all, are passed on to child elements, i.e. are inherited. Judiciously defining a base set of properties for the, styled, body element greatly simplifies the task of creating web pages which are compact and consistent. You should consider defining a body style with the following properties

All properties have a default value which is assumed if the property has not been styled. Generally speaking, little purpose is served by specifying such default values in a stylesheet. However, this is sometimes necessary in order to ensure consistent cross-browser rendition of the web page.

The body element is intended to serve as a container for other elements designed for more specific needs. Therefore, it should never contain any character data. However, most browsers are extremely fault-tolerant and will faithfully render text directly contained by the body element.

The elements contained inside the body element are, broadly speaking, of one of two types

Inline elements can in turn be considered to belong to one of two broad categories

We hasten to add that this distinction is a very fuzzy one. JavaScript can be used to impart interactivity to many "passive" elements. Indeed, even without the use of scripts it is possible to make passive elements interactive by using pseudo-class styling to create mouse hover effects etc. It is nevertheless useful to think in these terms in order to appreciate the significant role played by form controls. It must also be understood that it is in fact possible to display and use form controls - such as edit boxes and buttons - without placing them inside a form.

Jump To...

Colophon