ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
Last Update: 5 January 1998

4.6 DIV -- Block Divisions

HTML 3.2 introduced the element DIV, to allow you to block together other block body elements, and associate them together. This has practical purposes -- DIV can take the ALIGN attribute, and all blocks (P, BLOCKQUOTE, etc.) inside a DIV will inherit the text alignment specified by the outside DIV. Structurally, DIV can also take the CLASS attribute, which is used to specify the semantic meaning of the block. For example <DIV CLASS="abstract"> ..... </DIV> could be used to mark out the block of text that is a document's abstract. This is very useful when organizing text, and is much desired by document authors.

All modern browsers support the DIV element, but it is not supported by older browsers, such as Mosaic 2.0, Netscape Navigator 1.1 and Internet Explorer 2.0.

6.1.1 Example of DIV

The following is an example of DIV (look below to see how it displays on your browser):


<DIV ALIGN="center" CLASS="test_block">
  <h3> Test Heading -- how is it aligned?</h3>
  <P>Here is the first paragraph. This will be center-aligned if
     the browser understands DIV.
  <P ALIGN="left">
     This second paragraph should be left-aligned,
     as the ALIGN attribute of the paragraph element should override
     the alignment specified by the outer element.
</DIV>
here is some following text. If the browser does not understand
DIV this line will flow into the previous paragraph -- therefore
make sure, if using DIV, to properly block out all text within
and outside the DIV.

...which is displayed as:


Test Heading -- how is it aligned?

Here is the first paragraph. This will be center-aligned if the browser understands DIV.

This second paragraph should be left-aligned, as the ALIGN attribute of the paragraph element should override the alignment specified by the outer element.

here is some following text. If the browser does not understand DIV this line will flow into the previous paragraph -- therefore make sure, if using DIV, to properly block out all text within and outside the DIV.


ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
© 1994-1998 by Ian Graham
Last Update: 5 January 1998