The DIV Element

The <div> element is used to create sub-sections in a HTML document. It creates a generic block of document that should be treated as a logical unit and will have no default rendering or monitoring.

Syntax:
<div property=”value” property=”value” …. >
contents of the div
</div>

Valid Properties:
The <div> element has the following properties -
1. align The align property is used to align the contents within the div. The possible values are any one from the set – right, left, center, justify.

Other properties for the <div> element include the following common properties – class, dir, id, lang, style, title.

Refer to  Common Properties page for details of these properties.

Example:
<div align=”center”> This is a sample piece of text that is placed inside a div but is aligned at the center of the page as the megings of the div are yet to be set.</div>

Notes:
1. <div> element is a generic block tag and is very useful for binding scripts and/or styles to a section of the document. It complements the <span> element which is an inline element .
2. HTML 4.01 Strict version specification does not support the align attribute. So it should be used only with the Transitional version of HTML.
3. HTML 3.2 supports only the align property for the <div> element.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.