<Col> HTML Tag

In this article I will discuss the col tag of HTML.
  • 1981

The HTML <col> tag is used for specifying column properties for each column within a colgroup.The <col> tag defines attribute values for one or more columns in a table. This tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row. This tag can only be used inside a <table> or a <colgroup> element.

Example

<html>

<head>

    <title></title>

</head>

<body>

    <table border="1">

        <colgroup>

            <col style="background-color: red" />

            <col style="background-color: yellow" />

            <col style="background-color: Blue" />

            <col style="background-color: Gray" />

        </colgroup>

        <tr>

            <th>Employee_id</th>

            <th>Employee_name</th>

            <th>Employee_salary</th>

            <th>Employee_address</th>

        </tr>

        <tr>

            <td>101</td>

            <td>XYZ</td>

            <td>10000</td>

            <td>Delhi</td>

        </tr>

        <tr>

            <td>201</td>

            <td>ABC</td>

            <td>7000</td>

            <td>Noida</td>

        </tr>

        <tr>

            <td>205</td>

            <td>PQR</td>

            <td>8000</td>

            <td>Rampur</td>

        </tr>

    </table>

</body>

</html>


Output
 

Employee_id Employee_name Employee_salary Employee_address
101 XYZ 10000 Delhi
201 ABC 7000 Noida
205 PQR 8000 Rampur

Ask Your Question 

 
Got a programming related question? You may want to post your question here
 
© 2019 DotNetHeaven. All rights reserved.