col tag in HTML is used to set properties entire columns instead of individual cells.
coltag is placed inside the
colgrouptag is used to format a group of columns in a table.
col tag also supports style attributes of CSS.
The illustration below shows how the
col tag works in HTML:
col tag is written inside the
The syntax of
col tag is as follows:
<col attribute = value>
We open the tags using the
<> symbol. The keyword
col and related attributes come within.
Style attributes can be placed within the
col tag. Some prominent ones are listed below:
||Used to indicate the number of consecutive columns to apply the specified properties on. By default, the value is 1.|
||Changes the background color of the columns.|
||Changes the width of the column. Value in pixels|
||Changes the height of the column. Value in pixels|
The code snippet below shows how we can use the
col tag in HTML:
colgrouptags are part of the
tabletag in HTML.
coltag comes inside the
CSS style attributes can be used inside the
spanapplies style attributes to the number of columns specified. In our case, we styled the first two columns together.
We can also style a single column. In that case, we need not specify a value for
span. Instead, it chooses 1 by default. This is shown in the third column.
widthattribute adjusts the width of the column to the number of pixels specified. This is shown in the fourth column.
<td>tags are used to place rows, headings and data respectively.
View all Courses