|
The example of col tag in HTML
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<col align="right" style="background:#0099FF">
<col align="left">
<col align="left">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
Working example of col tag
The HTML col tag is used to define table column property for whole table's each column.
Col tag is useful for when we need to apply property to whole columns of the table. We need not define every time property for every column.
Col tag is used inside the table tag and defines at the top of the table tag.
Col tag can be used with colgroup tag in table.
Col tag is supported by all web browsers. These web browsers are Internet Explorer, firefox, opera and google chrome.
Col tag supports common attribute and event attributes.
Col tag Attribute
| Attribute |
Value |
Explaination |
| align |
left center right justify char |
Define the alignment of column |
| char |
Character |
alignment char, e.g. char=':' |
| charoff |
Length |
offset for alignment char |
| valign |
top middle bottom baseline |
Define vertical alignment attributes for cell contents |
| span |
NUMBER |
Define COL attributes affect N columns, |
| width |
NUMBER |
Define the width of a col tag |
Common Attribute of Col 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 Col 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 |
|