
本文介绍HTML colgroup align属性指定列组中内容的水平对齐方式。在 HTML5 中,不支持 <colgroup> align 属性。
在线示例
两个<colgroup>元素,它们为表中的三列指定不同的对齐方式(请注意,第一个<colgroup>元素跨越两列):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <colgroup> char 属性使用-大卫编程网(div.cn)</title>
<style>table, th, td {  border: 1px solid black;}</style>
</head>
<body>
<table style="width:100%">
  <colgroup align="left"></colgroup>
  <colgroup align="char" char="."></colgroup>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100.00</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$10.00</td>
  </tr>
</table>
</body>
</html>测试看看 ‹/›浏览器兼容性
IEFirefoxOperaChromeSafari
只有 Opera 和 Internet Explorer 8 及之前的版本(IE 9 不支持)支持 align 属性(IE 9 不支持)。
定义和用法
在 HTML5 中,不支持 <colgroup> align 属性。
align属性指定列组中内容的水平对齐方式。
语法
<colgroup align="left|right|center|justify|char">
属性值
| 值 | 描述 | 
|---|---|
| left | 左对齐内容(默认值)。 | 
| right | 右对齐内容。 | 
| center | 居中对齐内容(th 元素的默认值)。 | 
| justify | 对行进行伸展,这样每行都可以有相等的宽度(就像在报纸和杂志中)。 | 
| char | 将内容对准指定字符。 | 
