W3 3.2y
4.0y
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2y
2.1y

<DIV>...</DIV>

Description

This element is a general container for a part of the contents of a page. Through the DIV element you can add attributes, like style information, to this whole division. The DIV element will not show anything when used without any other attribute.

A division will terminate a paragraph opened with the P element.

<DIV align="center"> is the same as the deprecated <CENTER> element.

The difference between this element and the SPAN element is that the span element works inline, and the div element creates block-level content. With block-level content, most browsers surround the block by whitespace, starting at a new line.

DTD

<!ELEMENT DIV - - (%flow;)*            -- generic language/style container -->
<!ATTLIST DIV
  %attrs;                              -- %coreattrs, %i18n, %events --
>
from the HTML 4.0 DTD, "Copyright © W3C, (MIT, INRIA, Keio). All Rights Reserved."

Attributes

Core attributes: class id style title
Internationalization attributes: dir lang
Events: onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup

W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0n
4.0y
TV 1.2n
2.1y
ALIGN
This attribute defines how the contents of the division are aligned inside that division.

Value Description
CENTER Centers the contents between the margins of the division.
JUSTIFY This value will space the contents of the division evenly between the two margins of the division.

This value is not supported by the HTML 3.2 and Netscape Navigator 3.0.

LEFT Places the contents to the left side of the divison. This is the default alignment when the text direction is left to right.
RIGHT Places the contents to the right side of the divison. This is the default alignment when the text direction is left to right.

Netscape Navigator 4.0 has problems displaying the last line of a division when the division has a fixed width, set with a style sheet (see the examples).

Examples

Source
<DIV align="right">
This text is completely right-aligned which means that every line<BR>
aligns to the right side of the page.<BR>
<IMG src="IMG1.jpg" alt="A nice bird" width="56" height="100">
</DIV>
 
Result
This text is completely right-aligned which means that every line
aligns to the right side of the page.
A nice bird
 
Source
<DIV align="center" style="width: 200px;">
<EM>align="center"</EM><BR>
Hello there, this is just some text to see how the alignment of text inside a
division looks like. It's not a very interesting text, but I just had to have
some text to create the example.
</DIV>
 
Result
align="center"
Hello there, this is just some text to see how the alignment of text inside a division looks like. It's not a very interesting text, but I just had to have some text to create the example.
 
Source
<DIV align="justify" style="width: 200px;">
<EM>align="justify"</EM><BR>
Hello there, this is just some text to see how the alignment of text inside a
division looks like. It's not a very interesting text, but I just had to have
some text to create the example.
</DIV>
 
Result
align="justify"
Hello there, this is just some text to see how the alignment of text inside a division looks like. It's not a very interesting text, but I just had to have some text to create the example.
 
Source
<DIV align="left" style="width: 200px;">
<EM>align="left"</EM><BR>
Hello there, this is just some text to see how the alignment of text inside a
division looks like. It's not a very interesting text, but I just had to have
some text to create the example.
</DIV>
 
Result
align="left"
Hello there, this is just some text to see how the alignment of text inside a division looks like. It's not a very interesting text, but I just had to have some text to create the example.
 
Source
<DIV align="right" style="width: 200px;">
<EM>align="right"</EM><BR>
Hello there, this is just some text to see how the alignment of text inside a
division looks like. It's not a very interesting text, but I just had to have
some text to create the example.
</DIV>
 
Result
align="right"
Hello there, this is just some text to see how the alignment of text inside a division looks like. It's not a very interesting text, but I just had to have some text to create the example.
Statistics