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

HTML 参考手册

HTML 标签大全

HTML: <colgroup> align 属性

本文介绍HTML colgroup align属性指定列组中内容的水平对齐方式。在 HTML5 In HTML, the align attribute of <colgroup> is not supported.

 HTML <colgroup> tag

在线示例

两个<colgroup>元素,它们为表中的三列指定不同的对齐方式(请注意,第一个<colgroup>元素跨越两列):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <colgroup> char 属性使用-基础教程(oldtoolbag.com)</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>
Test see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Only Opera and Internet Explorer 8 and earlier versions (IE 9 Not supported) supports the align attribute (IE 9 Not supported).

Definition and Usage

In HTML5 In HTML, the align attribute of <colgroup> is not supported.

The align attribute specifies the horizontal alignment of the content within the column group.

Syntax

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

Attribute value

ValueDescription
leftLeft align the content (the default value).
rightRight align the content.
centerCenter align the content (the default value of the th element).
justifyStretch the line so that each line can have an equal width (as in newspapers and magazines).
charAlign content to a specified character.
 HTML <colgroup> tag