The <col> tag in HTML is used to set the column properties for each column within a <colgroup> tag. This tag is used to set the style property to each column. This tag does not contain closing tags.
Syntax:
<col attribute = "value">
Attributes: The various attributes that can be used with the col tag are listed below. Most of the attributes are not supported by HTML5.
- 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 the 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.
Example: The below example explains the HTML col Tag.
html
<!DOCTYPE html>
< html >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >HTML col Tag</ h2 >
< table >
< colgroup >
< col span = "1" style = "background-color: green" />
< col span = "1" style = "background-color: red" />
< col span = "1" style = "background-color: none" />
</ 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 >
|
Output:

Supported Browsers:
- Google Chrome 1 and above
- Edge 12 and above
- Internet Explorer
- Firefox 1 and above
- Opera
- Safari
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
21 Jul, 2022
Like Article
Save Article