HTML Tutorial

HTML Tag: <col>

Usage of <col>:

  • Defines a column in a <table> element.
  • Sets properties for all cells in that column.

Attributes of <col>:

Attribute Description
span Specifies how many columns this element should span.
width Defines the width of the column in pixels, percentage, or relative units.
align Aligns the content of the column (left, center, right).
valign Aligns the content of the column vertically (top, middle, bottom).
char Character used as a placeholder for text or images.
charoff Offset of the cell's content from the leading edge of the column.

Examples with <col>:

  1. Set a column width to 200 pixels:
<col width="200">
  1. Align all cells in a column to the right:
<col align="right">
  1. Define a column with a placeholder character "*":
<col char="*">

Exploring the <col> tag:

<table>
  <col width="200">
  <col>
  <col align="right">
  <tr>
    <td>Column 1</td>
    <td>Column 2</td>
    <td align="right">Column 3</td>
  </tr>
</table>

In this example:

  • Column 1 is 200 pixels wide.
  • Column 2 has the default width.
  • Column 3 is aligned to the right.