|
The example of caption tag in HTML
<table border="1">
<caption>This is caption tag</caption>
<tr>
<td>cell_1</td>
<td>cell_2</td>
</tr>
</table>
Working example of caption tag
This is caption tag
| cell_1 |
cell_2 |
The HTML caption tag is used to define caption name for table tag in webpage.
Caption tag is used with table tag of HTML and use inside of table tag. Caption tag should be written at top of table tag. The text inside caption tag display at table in webpage and default alignment is center.
Caption tag is supported by all web browsers. These web browsers are Internet Explorer, firefox, opera and google chrome.
Align attribute of caption is deprecated.
Caption tag supports common attribute and event attributes.
Caption tag attribute
| Attribute |
Value |
Explaination |
| align |
left
right
top
bottom |
Deprecated Define the alignment of caption |
Common Attribute of Caption 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 Caption 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 |
|