Latest web development tutorials

HTML <col> tag

Examples

<Colgroup> and <col> tag for the three columns in the table set the background color:

<table border="1">
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
</table>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support <col> tag.


Tag definitions and instructions

<col> tag specifies <colgroup> column attributes for each column element inside.

By using <col> tag, you can apply a style to an entire column, rather than requiring repeated for each cell in each row or set the style.


Differences between HTML 4.01 and HTML5

HTML5 no longer supported in HTML 4.01 in most of the properties.


Differences between HTML and XHTML

In HTML, <col> tag has no end tag.

In XHTML, <col> tag must be properly closed.


Attributes

属性 描述
align left
right
center
justify
char
HTML5 不支持。规定与 <col> 元素相关的内容的水平对齐方式。
char character HTML5 不支持。规定根据哪个字符来对齐与 <col> 元素相关的内容。
charoff number HTML5 不支持。规定第一个对齐字符的偏移量。
span number 规定 <col> 元素应该横跨的列数。
valign top
middle
bottom
baseline
HTML5 不支持。规定与 <col> 元素相关的内容的垂直对齐方式。
width %
pixels
relative_length
HTML5 不支持。 Specifies the width of a <col> element


Global Properties

<col> tag supports HTML global properties .


Event Properties

<col> tag supports HTML event properties .