English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <col> align Attribute

The align attribute specifies the horizontal alignment of the content related to the col element, the <col> tag specifies column attributes for each column within the <colgroup> element, and the <col> tag is very useful for applying styles to the entire column rather than repeating styles for each cell in each row.

 HTML <col> tag

Online Example

Use <colgroup> and <col> tags to set the background color of three columns:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8>
<title>HTML <col> align Attribute Usage<-Basic Tutorial(oldtoolbag.com)</title>
<style>table, th, td { border: 1px solid black;</style>
</head>
<body>
<table>
  <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>
  <tr>
    <td>5869207</td>
    <td>My first CSS</td>
    <td>49</td>
  </tr>
</table>
</body>
</html>
Test to see </›

Browser Compatibility

IEFirefoxOperaChromeSafari

Only Opera and Internet Explorer 8 and earlier IE versions support the align attribute (IE9This attribute is not supported).

Definition and Usage

HTML5 The <col> align attribute is not supported.

The align attribute specifies the horizontal alignment of the content related to the col element.

The <col> tag specifies column properties for each column within the <colgroup> element.

The <col> tag is very useful for applying styles to an entire column, rather than repeating the style for each cell in each row.

Syntax

<col align="left|right|center|justify|char">

Attribute value

ValueDescription
leftAlign content to the left (the default value).
rightAlign content to the right.
centerAlign content to center (the default value of the th element).
justifyExtend the line, so that each line can have an equal length (like in newspapers and magazines).
charAlign content to a specified character.
 HTML <col> tag