Tutorials Point


  HTML Home

  HTML Tags Reference
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

HTML <col> tag




Advertisements

Function:

The HTML <col> tag allows authors to group together attribute specifications for table columns. The <col> does not group columns together structurally -- that is the role of the <colgroup> element.

The <col> elements are empty and serve only as a support for attributes.

Difference between HTML and XHTML:

In HTML the <col> tag has no end tag.

In XHTML the <col> tag must be properly closed.

Example:

<p>This example shows a colgroup that has three columns of different widths:</p>

<table border="1">
<colgroup span="3">
<col width="50"></col>
<col width="100"></col>
<col width="200"></col>
</colgroup>
<tr>
<td>col 1</td>
<td>col 2</td>
<td>col 3</td>
</tr>
</table>

This will produce following result:

This example shows a colgroup that has three columns of different widths:

col 1 col 2 col 3

Online Practice:

To Become more comfortable - Do Online Practice

Attributes:

AttributeValueDescription
alignright
left
center
justify
char
Defines horizontal alignment
charcharacterDefines a character to use to align text on (use with align="char").
charoffpixelSpecifies an alignment offset (either in pixels or percentage value) against the first character as specified with the char attribute.
spannumberDefines the number of columns the <col> should span
valignbottom
middle
top
baseline
Defines vertical alignment
widthpixels or %Specifies a default width for each column spanned by the current col element

Standard Attributes:

AttributeDescription
classDocument wide identifier
dirSpecifies the direction of the text
idDocument wide identifier
titleSpecifies a title to associate with the element.
styleHelps to include inline casecadubf style sheet.
langSets the language code.

Event Attributes:

AttributeDescription
onclickScript runs when a mouse click
ondblclickScript runs when a mouse double-click
onmousedownScript runs when mouse button is pressed
onmouseupScript runs when mouse button is released
onmouseoverScript runs when mouse pointer moves over an element
onmousemoveScript runs when mouse pointer moves
onmouseoutScript runs when mouse pointer moves out of an element
onkeypressScript runs when key is pressed and released
onkeydownScript runs when key is pressed
onkeyupScript runs when key is released

Printer Friendly

Advertisements


  

Advertisements