Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use <col> tag correctly and is it supported in all browser?

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>
like image 623
Jitendra Vyas Avatar asked Jun 11 '10 16:06

Jitendra Vyas


People also ask

What is the use of Col tag?

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.

Is Colgroup deprecated?

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.

What does Cols do in HTML?

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.

How do you arrange columns in HTML?

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.


2 Answers

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.

like image 160
Guffa Avatar answered Sep 24 '22 10:09

Guffa


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.

like image 38
VoodooChild Avatar answered Sep 24 '22 10:09

VoodooChild