HTMLforall

  HTML | PHP | Forum

HTML <col> tag

Syntax

<col> - </col>

Definition and Usage

The COL element 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. COL elements are empty and serve only as a support for attributes.

If used, COL must be after the optional CAPTION and before the optional THEAD in the TABLE. Unlike COLGROUP, COL does not group columns structurally; it merely defines attributes common to all cells in one or more columns.

Optional Attributes

Attribute Value Description
align right
left
center
justify
char
Defines the horizontal alignment of the content in the table cell, in the column
char character Defines a character to use to align text on (use with align="char")
charoff pixels
%
Defines an alignment offset to the first character to align on, as set with char
span number Defines the number of columns the <col> should span
valign top
middle
bottom
baseline
Defines the vertical alignment of the content in the table cell, in the column
width %
pixels
relative_length
Defines the width of the column.

Note: Overrides the width set in <colgroup>

Standard Attributes

id, class, title, style, dir, lang, xml:lang

For a full description, go to Standard Attributes.

Event Attributes

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to Event Attributes.

Example

Source Output
This example shows a table that has three columns of different widths:
<table border="2">
<colgroup span="3">
<col width="25"></col>
<col width="45"></col>
<col width="65"></col>
</colgroup>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
This example shows a table that has three columns of different widths:
1 2 3

Home

Learn HTML
HTML Tutorial

HTML Reference
HTML by function
HTML by Alphabet

HTML events
HTML attributes
HTML color names

Top-Level Elements
<!--...-->
<!DOCTYPE> 
<html>
<head>
<body>
<frameset>
Head Elements
<base>
<isindex>
<link>
<meta>
<script>
<style>
<title>
Generic Block-level Elements
<address>
<blockquote>
<center>
<del>
<div>
<h1> to <h6>
<hr>
<ins>
<isindex>
<noscript>
<p>
<pre>
Lists
<dd>
<dir>
<dl>
<dt>
<li>
<menu>
<ol>
<ul>
Tables
<caption>
<col>
<colgroup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<tr>
Forms
<button>
<fieldset>
<form>
<input>
<label>
<legend>
<option>
<optgroup>
<select>
<textarea>
Special Inline Elements
<a>
<applet>
<area>
<basefont>
<bdo>
<br>
<font>
<iframe>
<img>
<map>
<object>
<param>
<q>
<script>
<span>
<sub>
<sup>
Phrase Elements
<abbr>
<acronym>
<cite>
<code>
<del>
<dfn>
<em>
<ins>
<kbd>
<samp>
<strong>
<var>
Font Style Elements
<b>
<big>
<i>
<s>
<small>
<strike>
<tt>
<u>
Frames
<frame>
<frameset>
<noframes>

 

Copyright 2005-8 Sunilcare.  All Rights Reserved.
Comments or suggestions? Contact us.About us