HTML | col Tag

The <col> tag in HTML is used to set the column properties for each column within a <colgroup> element. This tag is used to set the style property to each column. This tag does not contain closing tags.

Syntax:

<col attribute = "value">

Attributes



  • span: It is used to define the number of columns on which property will be applied.
  • style: This attribute is used to define the CSS to change the properties of column.
  • align: This attribute is used to set the alignment of the content of <col> element.
  • width: It is used to specify the width of a <col> element.
  • charoff: It is used to specify the number of characters the content will be aligned from the character specified by the char attribute.

Note: Most of the attributes are not supported by HTML5.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>col</title>
    </head>
    <body>
        <table border="1">
            <caption>Author Details</caption>
              
            <colgroup>
                  
                <!-- col tag starts from here --> 
                <col span="1" style="background-color:green">
                <col span="2" style="background-color:none">
                <!-- col tag ends here. col tag does not 
                contains ending tag -->
                  
            </colgroup>
              
            <tr>
                <th>NAME</th>
                <th>AGE</th>
                <th>BRANCH</th>
            </tr>
            <tr>
                <td>BITTU</td>
                <td>22</td>
                <td>CSE</td>
            </tr>
            <tr>
                <td>RAM</td>
                <td>21</td>
                <td>ECE</td>
            </tr>
        </table>
    </body>
</html>                    

chevron_right


Output:
GeeksForGeeks

Supported Browsers: The browser supported by <col> tag are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.