TAG:  div

<div> ... </div>
 
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 separate closing tag is mandatory.
 
Attributes and Events
 
class    dir    id    lang    onclick    ondblclick    onkeydown    onkeypress    onkeyup    onmousedown    onmousemove    onmouseout    onmouseover    onmouseup    style    title
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML div Tag Example</title>
</head>
<body>
<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>
</body>
</html>

 
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