O'Reilly logo

Dynamic HTML: The Definitive Reference by Danny Goodman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

<DIV> — NN all IE all HTML 3.2

Synopsis

<DIV>...</DIV>

End Tag: Required

The DIV element gives structure and context to any block-level content in a document. Unlike some other structural elements that have very specific connotations attached to them (the P element, for instance), the author is free to give meaning to each particular DIV element by virtue of the element’s attribute settings and nested content. Each DIV element becomes a generic block-level container for all content within the required start and end tags.

As a basic example, the DIV element is now recommended as the element to use to center text on a page, in place of the deprecated CENTER element. The DIV element that does the work includes style information that takes care of the centering of the content. It is also convenient to use the DIV element as a wrapper for multielement content that is to be governed by a single style sheet rule. For example, if a block of content includes three paragraphs, rather than assign a special font style to each of the P elements, you can wrap all three P elements with a single DIV element whose style sheet defines the requested font style. Such a style sheet could be defined as an inline STYLE attribute of the DIV element or assigned via the CLASS or ID attribute, depending on the structure of the rest of the document.

DIV elements are block-level elements. If you need an arbitrary container for inline content, use the SPAN element, instead.

HTML 4.0 defines many more attributes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required