col Tag in HTML

1
127

The <col> tag in HTML is used to define properties for a group of table columns. It is typically used in conjunction with the <colgroup> tag to specify common attributes for a set of table columns.

The <col> tag can be used to define various properties such as the width, alignment, and background color of the columns.

Here is an example of how the <col> tag can be used:

<table>
<colgroup>
<col style=”background-color: yellow;”>
<col>
<col>
</colgroup>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
</tr>
</table>

Also Read:  big Tag in HTML

In this example, the <col> tag is used to define the background color of the first column in the table. The <col> tag can also be used to specify other attributes such as width and alignment, as follows:

<table>
<colgroup>
<col style=”width: 30%;”>
<col style=”text-align: center;”>
</colgroup>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>

In this example, the first column is set to be 30% of the table width, while the second column is centered.

1 COMMENT

Leave a Reply