span tag
br tag
p tag
style tag
TAG: div
<div> ... </div>
Available in versions: 3.2, 4.0
Browser compatibility: Explorer 4, 5 Netscape 6
The
<div>
tag is used to designate a block-line portion of an HTML document as a
div
element and to apply any of the core attributes of this tag against the contents of that element. The behavior of this tag is block-line, because this tag causes a line break (the equivalent of a
br
tag) to occur both before and after the
div
element.
div
tags, which can be nested, allow a significant degree of control and manipulation of each individual block section of your web page.
For example, you could use the
class
or
style
core attributes to apply the effects of Cascading Style Sheets, or you could use the
lang
attribute to display a foreign language text, or you could assign an
id
to each block of code for reference by a hyperlink.
In contrast, you should use the
span
tag when you want to apply attributes to an inline portion of a page. Note that the behavior of the
span
tag is not block-line, but rather inline, since the effects occur in the normal flow of the text and images (without the tag inserting any additional linefeeds or carriage returns).
With the advent of Cascading Style Sheets, both the
div
and
span
tags have gained importance and usefulness.
The ending tag is optional. However, it is recommended that it be included.
Core Attributes
class
dir
id
lang
onclick
ondblclick
onkeydown
onkeypress
onkeyup
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
style
title
Attributes
align
deprecated 4.0
The
align
attribute is used to set the position of the contents of the
div
tag. The permitted values are
center, justify, left,
and
right
. This attribute is deprecated effective with version 4.0. However, most browsers continue to recognize this attribute. You are now to use style sheets.
Code:
<div style="text-align: left;" id="div_example1">
The <b>div</b> offers exciting possibilities for the developer.
</div>
<div style="text-align: center;" id="div_example2">
You should take time to learn about this tag.
</div>
<div style="text-align: right;" id="div_example3">
Also check out the <b>span</b> tag.
</div>
Output:
The
div
offers exciting possibilities for the developer.
You should take time to learn about this tag.
Also check out the
span
tag.
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information