Advertisement

HTML <col> tag

Examples

col elements are three columns in the table specifies a different alignment:

<table width="100%" border="1">
  <col align="left" />
  <col align="left" />
  <col align="right" />
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
</table>

Try it yourself

Browser Support

IE Firefox Chrome Safari Opera

All major browsers support <col> tag.

Definition and Usage

<Col> tag to the table one or more columns defined property values.

To apply a style to all columns, <col> tag is useful, so there is no need for each unit and each row of the pattern repeat application.

You can only use <col> tag in a table or colgroup element.

Differences between HTML and XHTML

In HTML, <col> tag is not over.

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

Tips and Notes:

Tip: Add tag class attribute <col>. So that you can use CSS to be responsible for the alignment, width and color, and so on.

Tip: If you want to colgroup inside different predetermined property values for each column, use this element. If there is no element col, row inherit all the property values ​​from colgroup there.

NOTE: col element is an empty element that contains only attributes. To create a column, you must specify td elements within tr elements.

See: <COLGROUP> tag .

Optional attributes

Attributes value description
align
  • right
  • left
  • center
  • justify
  • char
The horizontal alignment of the provisions of the col element related content.
char character According to the provisions of which character to align with the col element related content.
charoff number The provisions of an offset alignment character.
span number Should the number of columns specified col element spanned.
valign
  • top
  • middle
  • bottom
  • baseline
Definition and col elements related content vertical alignment.
width
  • pixels
  • %
  • relative_length
Predetermined width col element.

Global Properties

<col> tag supports HTML in the global properties .

Event Properties

<col> tag supports HTML in the event properties .

Related Pages

HTML DOM Reference Manual: the Column Object