Loading...
HTML <col> Tag

HTML <col> Tag

In this tutorial, we will learn about col tag in HTML with the help of examples.


<col> Tag

Col tag <col> is used to specify column properties for each column within a <colgroup> tag.

Note : The <col> tag is used for applying the style to entire columns in a row, instead of repeating the styling for each column.

Syntax

<col>.....</col>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Col Tag</title>
  </head>
  <body>
    <table>
      <colgroup>
        <col span = "1" style = "background-color : red">
        <col span = "1" style = "background-color : yellow">
        <col span = "1" style = "background-color : greenyellow">
      </colgroup>
      <tr>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Age</th>
      </tr>
      <tr>
        <td>Sunny</td>
        <td>Chaudhary</td>
        <td>20</td>
      </tr>
      <tr>
        <td>Anu</td>
        <td>Chaudhary</td>
        <td>19</td>
      </tr>
    </table>
  </body>
</html>

Output

First NameLast NameAge
SunnyChaudhary20
AnuChaudhary19

Specific Attribute

Attribute Value Description
align right
left
center
justify
char
Defines the horizontal alignment of the columns
char character Define a character to use to align the text
charoff pixel Specifies an alignment offset (either in px or percentage value) against the first character as specified with the char attribute
span number Defines the number of columns the <col> should span
valign bottom
middle
top
baseline
Defines verticle alignment
width pixels
percentage
Specifies a default width for each column spanned by the current <col> element

Global Attribute

Col Tag support all the global attributes of HTML.


Event Attribute

Col Tag support all the event attributes of HTML.


Next Tutorial

We hope that this tutorial helped you develop better understanding of the concept of col tag in HTML.

Keep Learning : )

In the next tutorial, you'll learn about HTML colgroup Tag.

- Related Topics