What is the use of <col>
tag and is it supported in all browser?
I was trying <col style="background:red">
but it's not working. I'm on Firefox 3.
<table width="100%" border="1">
<col style="background:red">
<caption> Table Caption </caption>
The <col> tag specifies column properties for each column within a <colgroup> element. The <col> tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.
However, most of the HTML colgroup attributes have been deprecated, and they are shown in the following list: align – used to specify the horizontal alignment of each column cell. bgcolor – used to alter the background color of the cells.
The cols attribute specifies the visible width of a text area. Tip: The size of a textarea can also be set by the CSS height and width properties.
The following syntax is used to add columns in HTML. <div class="row"> tag is used to initialize the row where all the columns will be added. <div class="column" > tag is used to add the corresponding number of columns. style="background-color:#aaa;" property is used to give color to the column.
It works, but it doesn't affect the caption. Working example:
<html>
<head>
<title></title>
</head>
<body>
<table>
<caption>test</caption>
<col style="background:red" />
<col style="background:blue" />
<tr>
<td>red</td>
<td>blue</td>
</tr>
<tr>
<td>red</td>
<td>blue</td>
</tr>
</table>
</body>
</html>
The tag is defined in HTML 4.01 (1997) and not deprecated in XHTML, so it should be supported (as far as the user interface allows) by every current browser on any platform.
It is used in tables to set default attributes for all the cells in a column or a group of columns.
The col tag is defined in an ordered way and can be part of a HTML colgroup tag or not.
It is supported in all browsers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With