Learning HTML 3.2 by Examples, section 5 Descriptions of HTML 3.2 tags:

DIV - document division (Not in HTML 2.0!)


To specify document division. The ALIGN attribute allows different alignments (left, center, right) to be used in different parts of the document.

The DIV element can also be used in conjunction with style sheets in order to affect the rendering of parts of a document in various ways.

Typical rendering

The part of document is aligned according to the ALIGN attribute of the element.

Basic syntax

<DIV ALIGN=alignment>
a section of the document

Possible attributes

attribute name possible values meaning notes
ALIGN LEFT, CENTER, RIGHT alignment of text within the element deprecated in HTML 4.0

The ALIGN attribute specifies the default alignment; it can be overridden by ALIGN attributes in enclosed elements (e.g. P elements).

Allowed context

Block container.


Headings, text elements, block elements, and ADDRESS elements.


Example DIV-1.html:

This is a normal paragraph which will be rendered according to
default alignments, which usually means left alignment.
This is text which will be centered.
This is a longer text paragraph which will be centered.
It is so long that line breaks will most probably occur.
Notice that the division into lines is usually not the same
as in the HTML file.
The following example shows how to present (poetic) text as centered and with a particular division into lines:

Example DIV-2.html:

Mieleni minun tekevi<BR>
aivoni ajattelevi<BR>
lähteäni laulamahan<BR>
saa'ani sanelemahan.<BR>


In HTML 4.0, the ALIGN attribute is deprecated .

Since DIV is a block-like element, it terminates an open P element ( i.e. causes the browser to assume an implied </P> tag when necessary). Other than this, browsers are not expected to render paragraph breaks before and after DIV elements. If paragraph breaks are desired, you can use the P element with an ALIGN attribute instead.

Date of last update: 2010-12-16.
This page belongs to the free information site IT and communication, section Web authoring and surfing, by Jukka "Yucca" Korpela.