|
The example of div tag in HTML
<div style="background:#00CCFF">Div block 1</div>
<div style="border:1px solid #666666">Div block 2</div>
Working example of div tag
Div block 1
Div block 2
The HTML div tag is used to define particular section or block in webpage.
If two div tag is used together, it second div tag block is shown next line.
Div tag is useful when information is shown in blocks.
Align attribute of div tag is deprecated by HTML 4.01 DTD, and it cannot use in Strict HTML DTD version.
Div tag is supported by all web browsers. These web browsers are Internet explorer, firefox, opera, google chrome.
Div tag supports all common attribute and event attributes.
Div tag Attribute
| Attribute |
Value |
Explaination |
| align |
left center right justify |
Deprecated Define alignment of div block |
Common Attribute of div Tag
| Attribute |
Value |
Explaination |
| id |
ID |
unique id document for element |
| class |
classname |
list of CSS classes |
| style |
StyleSheet |
associated style information of style tags |
| title |
Text |
information about an element shown on mouse over cursor |
| lang |
LanguageCode |
Language Code of the element |
| dir |
ltr rtl |
direction for weak/neutral text |
Events Attribute of Div Tag
| Attribute |
Value |
Explaination |
| onclick |
event |
Event Fire on mouse button was clicked |
| ondblclick |
event |
Event Fire on a mouse button was double clicked |
| onmousedown |
event |
Event Fire on a mouse button was pressed down |
| onmouseup |
event |
Event Fire on a mouse button was released |
| onmouseover |
event |
Event Fire on a mouse was moved onto |
| onmousemove |
event |
Event Fire on a mouse was moved within |
| onmouseout |
event |
Event Fire on a mouse was moved away |
| onkeypress |
event |
Event Fire on a key was pressed and released |
| onkeydown |
event |
Event Fire on a key was pressed down |
| onkeyup |
event |
Event Fire on a key was released |
|