The HTML <col> Element (or HTML Table Column Element) defines a column within a table and is used for defining common semantics on all common cells. It is generally found within a <colgroup> element.

Must be used within a HTML colgroup element that doesn't have a span attribute.

Required Attributes

  • None.

Optional Attributes

  • span can be used to specify a number of columns.
  • align can be used to horizontally align the cells within the column. The value can be left, center, right, justify or char.
  • valign can be used to vertically align the cells within the column. The value can be top, middle, bottom or baseline.
  • char can be used to specify a character with which cells will align, such as a decimal point. It is not supported by any major browser.
  • charoff can be used to specify the number of pixels the alignment should be offset from the char character. It is not supported by any major browser.
  • Common attributes

Example

<table>
	<colgroup>
		<col class="column1" />
		<col class="column2" />
		<col class="columns3and4" span="2" />
	</colgroup>
	<tr>
		<th>lion</th>
		<th>meerkat</th>
		<th>warthog</th>
		<th>baboon</th>
	</tr>
	<tr>
		<td>Simba</td>
		<td>Timon</td>
		<td>Pumba</td>
		<td>Rafiki</td>
	</tr>
</table>

Changes in HTML5

  • None.

Related Tags