HTML <colgroup>标签用于为表中的一组列指定属性。
如果需要将不同的属性应用于colgroup中的列,则可以使用colgroup标签中的HTML col标签。
colgroup示例
<!DOCTYPE html> <html> <head> <title>HTML colgroup Tag</title> </head> <body> <p>This example shows a colgroup that has three columns of different widths:</p> <table border="1"> <colgroup span="3"> <col width="50"></col> <col width="100"></col> <col width="200"></col> </colgroup> <tr> <td>col 1</td> <td>col 2</td> <td>col 3</td> </tr> </table> </body> </html>
这将产生以下结果-
全局属性
此标签支持HTML 中描述的所有全局属性。
特定属性
HTML <colgroup>标签还支持以下附加属性-
| Attribute | Value | 描述 |
|---|---|---|
| align | right left center justify char |
定义水平对齐, HTML5不支持。 |
| char | character | 定义一个用于对齐文本的字符(与align =“ char”一起使用),HTML5不支持。 |
| charoff | pixel | 指定与char属性指定的第一个字符的对齐偏移量(以像素或百分比值表示), HTML5不支持。 |
| span | number | 定义<col>应该跨越的列数,HTML5不支持。 |
| valign | bottom middle top baseline |
定义垂直对齐,HTML5不支持。 |
| width | pixels or % | 为当前col元素跨越的每一列指定默认宽度, HTML5不支持。 |
事件属性
此标签支持HTML 中描述的所有事件属性。
浏览器支持
| Chrome | Firefox | IE | Opera | Safari | Android |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |