HTML Tags
Advertisements

HTML <col> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <col> tag represents one or more columns in the column-group defined by the <colgroup> element. It is useful for applying style rules to entire columns, rather than repeating the styles for each cell, row after row.

The following table summarizes the usages context and the version history of this tag.

Parent: <colgroup>, <table>
Content: None. It is an empty element.
Start/End Tag: Start tag: required, End tag: forbidden
Version: HTML 4, 4.01, 5

Syntax

The basic syntax of the <col> tag is given with:

HTML:<col>; XHTML:<col />

The example below shows the <col> tag in action.

<table>
    <colgroup>
        <col style="background-color:#adff2f;">
        <col span="2" style="background-color:#f0e68c;">
    </colgroup>
    <tr>
        <th>No.</th>
        <th>Name</th>
        <th>Email</th>
    </tr>
    <tr>
        <td>1</td>
        <td>John Carter</td>
        <td>johncarter@mail.com</td>
    </tr>
    <tr>
        <td>2</td>
        <td>Peter Parker</td>
        <td>peterparker@mail.com</td>
    </tr>
    <tr>
        <td>3</td>
        <td>John Rambo</td>
        <td>johnrambo@mail.com</td>
    </tr>
</table>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <col> tag.

Attribute Value Description
align left
right
center
justify
char
Obsolete Specifies the horizontal alignment of content within each cell of the related column.
char character Obsolete Sets the character to which cell contents should align.
charoff number Obsolete Defines the number of characters by which cell contents will be offset from the alignment characters specified by the char attribute.
span length Specifies the number of consecutive columns the <col> element spans. The default value is 1. Negative value is not allowed.
valign top
middle
bottom
baseline
Obsolete Specifies the vertical alignment of content within each cell of the related column.
width length Obsolete Specifies a default width for each column in the current column group.

Global Attributes

Like all other HTML tags, the <col> tag supports the global attributes in HTML5.


Event Attributes

The <col> tag also supports the event attributes in HTML5.


Browser Compatibility

The <col> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 7+

Further Reading

See tutorial on: HTML Tables.

Related tags: <colgroup>, <table>.

Advertisements
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties