HTML <col /> tagS2C Home   « HTML <col /> tag

Definition

The <col /> tag is a self closing tag used to define criteria for a table column.

Example


<table border="1">
  <col span="2" width="200" />
  <col  width="75" />
  <tr>
    <th>Fruit</th>
    <th>Colour</th>
    <th>Quantity</th>
  </tr>
  <tr>
    <td>Banana</td>
    <td>Yellow</td>
    <td>5</td>
  </tr>
  <tr>
    <td>Pea</td>
    <td>Green</td>
    <td>50</td>
  </tr>
</table>

Required Attributes

NONE

Optional Attributes

align - limited browser support - use CSS instead.

char no browser support - specifies character to align cells to.

charoff no browser support - specifies offset of char character in pixels.

valign - limited browser support - use CSS instead.

span specifies the number of columns in a group.


<col span="4" />

width specifies the column group width.


<col width="30" />   <!-- in pixels -->
<col width="25%" />   <!-- as a percentage -->

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<col class="classname" />

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<col id="idname" />

style - specifies an inline style for the element allowing you to apply the style to the content.


<col style="color:red;text-align:left" />

title - specifies extra information about the content.


<col title="information about the content" />

Language Attributes

dir - specifies the directional flow of the content.


<col dir="ltr" />   <!-- The text will flow from left to right -->

<col dir="rtl" />   <!-- The text will flow from right to left -->

lang - specifies a language code for the content of the element.


<col lang="en" />

xml:lang - specifies a language code for the content of the element in XHTML documents.


<col xml:lang="fr" />

Document Event Attributes

NONE

Form Event Attributes

NONE

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<col onkeydown="go()" />   <!-- Executes the go() function -->

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<col onkeypress="go()" />   <!-- Executes the go() function -->

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<col onkeyup="go()" />   <!-- Executes the go() function -->

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<col onclick="go()" />   <!-- Executes the go() function --> 

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<col ondblclick="go()" />   <!-- Executes the go() function -->

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<col onmousedown="go()" />   <!-- Executes the go() function -->

onmousemove - The JavaScript code to be run when the mouse button is moved.


<col onmousemove="go()" />   <!-- Executes the go() function -->

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<col onmouseout="go()" />   <!-- Executes the go() function -->

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<col onmouseover="go()" />   <!-- Executes the go() function -->

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<col onmouseup="go()" />   <!-- Executes the go() function -->

go to home page Homepage go to top of page Top