Next / Previous / Contents / TCC Help System / NM Tech homepage

9.5. The div element: A generic block container

The purpose of the div element is to hold a block-shaped chunk of content. Its content will occupy a rectangular area on your document when it is rendered. It is similar to the p (paragraph) element.

The main reason XHTML has a div element, in addition to a p element, is to allow you to create blocks of content that have specific style rules determined by a CSS stylesheet. Typically, you will use a div element with a class attribute to identify what kind of block you want, and then write a CSS rule that applies to that particular type of element and class attribute.

Here is the content model:

element div
{ Common.attrib,

All the attributes defined in Section 15.3, “The common attributes: Common.attrib can be used in a div element.


The content inside a div element can be any mixture of inline elements, block elements, or text. See Section 12, “Flow.model: Arbitrary content”.

Here is an example of a div element.

  <div class='warning'>
    Be sure to inflate shoes before crossing the water.