16
2008.6
看了《TheBest-Practice Guide to XHTML and CSS》一书,里面提到了个“colgroup”列组的属性,觉得很有用,在这里记一下,以备不时之需。在这里要感谢htmldog给我们免费提供了一本基础详细实用的好书。
虽然table是按行组建的,但你仍然可以通过“colgroup”和“col”两个元素来寻址列或一组列,还能给它们设置属性,比如“class”。
你可以通过“bolgroup”来给一列设置属性,也可以使用“span”来给一组列设置属性,而“span”的用法和“rowspan”、“colspan”的用法是一样的。看下面的实例代码:
<table>
<caption>Caption</caption>
<colgroup>
<col />
<col class="alternative" />
<col span="2" class="alternative" />
</colgroup>
<tr>
<td>This</td>
<td>That</td>
<td>The other</td>
<td>Lunch</td>
<td>Lunch</td>
</tr>
<tr>
<td>Ladybird</td>
<td>Locust</td>
<td>Lunch</td>
<td>Lunch</td>
<td>Lunch</td>
</tr>
</table>



