使用 <colgroup> span 属性设置前两列的背景颜色:
<table> <colgroup span="2" style="background:red"></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> <tr> <td>5869207</td> <td>My first CSS</td> <td>$49</td> </tr> </table>
span 属性定义了 <colgroup> 元素应该跨越的列数。
提示: 要为 <colgroup> 中的列定义不同的属性,请使用 <colgroup> 标记中的 <col> 标记。
| Attribute |
|
|
|
|
|
|---|---|---|---|---|---|
| span | Yes | Yes | Yes | Yes | Yes |
<colgroup span="number">
| 值 Value | 描述 Description |
|---|---|
| number | 设置列组应跨越的列数 |