html <colgroup> 标签
- <col>
- <command>
实例
两个 colgroup 元素为表格中的三列规定了不同的对齐方式和样式(注意第一个 colgroup 元素横跨两列):
<table width="100%" border="1"> <colgroup span="2" align="left"></colgroup> <colgroup align="right" style="color:#0000ff;"></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>
亲自试一试
浏览器支持
元素 chrome ie firefox safari opera<colgroup> | yes | yes | yes | yes | yes |
所有主流浏览器都支持 <colgroup> 标签。
firefox、chrome 以及 safari 仅支持 colgroup 元素的 span 和 width 属性。
定义和用法
<colgroup> 标签用于对表格中的列进行组合,以便对其进行格式化。
如需对全部列应用样式,<colgroup> 标签很有用,这样就不需要对各个单元和各行重复应用样式了。
<colgroup> 标签只能在 table 元素中使用。
html 与 xhtml 之间的差异
none
提示和注释:
提示:请为 <colgroup> 标签添加 class 属性。这样就可以使用 css 来负责对齐方式、宽度和颜色等等。
注释:col 元素是仅包含属性的空元素。如需创建列,您就必须在 tr 元素内部规定 td 元素。
参见:<col> 标签。
可选的属性
属性 值 描述align |
|
定义在列组合中内容的水平对齐方式。 |
char | character | 规定根据哪个字符来对齐列组中的内容。 |
charoff | number | 规定第一个对齐字符的偏移量。 |
span | number | 规定列组应该横跨的列数。 |
valign |
|
定义在列组合中内容的垂直对齐方式。 |
width |
|
规定列组合的宽度。 |
全局属性
<colgroup> 标签支持 html 中的全局属性。
事件属性
<colgroup> 标签支持 html 中的事件属性。
相关页面
html dom 参考手册:column 对象
- <col>
- <command>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!