<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>
通过<colgroup>标签可以系统化的向整个列应用样式,从而不需要反复的对每一个单元格或者一行进行操作。
<table> 元素之内,在任何一个 <caption> 元素之后,在任何一个 <thead>、<tbody>、<tfoot>、<tr> 元素之前使用 <colgroup> 标签。<colgroup> 中的某列定义不同的属性,请在 <colgroup> 标签内使用 <col> 标签。
相关文章推荐: