<col> tag

HTML <col> tag

The <col> tag defines the properties for each column within <colgroup>.

It is basically used to style the columns.

Syntax:
<col style=”css properties”>

Note/Info:
You must have the basic knowledge of CSS to use the style attribute.

Example

<table>
 <colgroup>
   <col span="3" style="background-color:skyblue">
   <col style="background-color:lightpink">
 </colgroup>
 <tr>
   <th>BIG DATA </th>
   <th>DIGITAL MARKETING</th>
   <th>MAINFRAME </th>
   <th>PROJECT MANAGEMENT </th>
 </tr>
 <tr>
   <td>Spark</td>
   <td>SEO</td>
   <td>COBOL</td>
   <td>Agile</td>
 </tr>
 <tr>
   <td>Scala</td>
   <td>Social Media</td>
   <td>DB2</td>
   <td>Prince2</td>
 </tr>
 <tr>
   <td>HBase</td>
   <td>Content</td>
   <td>JCL</td>
   <td>PMP</td>
 </tr>
 <tr>
   <td>Kafka</td>
   <td>Analytics</td>
   <td>CICS</td>
   <td>ITIL</td>
 </tr>
</table>

Default CSS Value

display:table-column;

How Browser will display

TABLE.

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
<col> tag has no End tag <col> tag must be closed as <col.. /> All the <col> tag attributes of HTML4.1 is not supported in HTML5

Attributes used with <col> tag

Attribute Description
span To set a positive number of columns, each column element can span. The default value is 1.
align To align the content of a each column element to left, right, center, justify or char.
(HTML5 does not support this attribute when it is used with the <col> tag).
char To align the content of each column element in character.
(HTML5 does not support this attribute when it is used with the <col> tag).
charoff To align the number of characters from which the content will align from the character set by the char attribute. This uses a number for this purpose.
(HTML5 does not support this attribute when it is used with the <col> tag).
valign To align the content of each column element vertically in a column element to top, bottom, middle or baseline.
(HTML5 does not support this attribute when it is used with the <col> tag).
width Sets the width of each column element in %, pixels or relative_length units.
(HTML5 does not support this attribute when it is used with the <col> tag).

Global Attributes

The <col> tag supports Global attributes.

Event Attributes

The <col> tag supports Event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

<table><caption><thead><tbody><tr> ,   <colgroup> and <tfoot>  tags.

Tutorials for all brains!