<colgroup> 标签

<colgroup> 标签用于对表格中的列进行组合,以便对其进行格式化。 如需对全部列应用样式,<colgroup> 标签很有用,这样就不需要对各个单元和各行重复应用样式了。

实例

<colgroup> 和 <col> 标签为表格中的三个列设置了背景色:

<table border="1">
  <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>
</table>

可选的属性

属性描述
align right
left
center
justify
char
定义在列组合中内容的水平对齐方式。
char character 规定根据哪个字符来对齐列组中的内容
charoff number 规定第一个对齐字符的偏移量
span number 规定列组应该横跨的列数
valign top
middle
bottom
baseline
定义在列组合中内容的垂直对齐方式。
width pixels
%
relative_length
规定列组合的宽度。
posted @ 2020-11-10 19:24  Millychen  阅读(100)  评论(0)    收藏  举报