在table表格中, 我们很方便的使用tr表示一行,
而col和colgroup作为列和列组使用, 弥补了表格列的空白
col标签表示列
这个标签可以快速的指定一列的样式
<table border="1">
<col span="2" style="background-color:red">
<col style="background-color:yellow">
<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>
列组合标签colgroup
在它包裹的列, 表示一个组合, 可以对组合的列设置统一的属性
<table border="1">
<colgroup style="background-color:red" >
<col >
<col >
</colgroup>
<col style="background-color:yellow">
<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>
col与colgroup可选属性
它们的可选属性是相同的
属性 | 值 | 描述 |
---|---|---|
align | left right center justify char | HTML5 不支持。规定在列组合中内容的水平对齐方式。 |
char | character | HTML5 不支持。规定根据哪个字符来对齐列组中的内容。 |
charoff | number | HTML5 不支持。规定第一个对齐字符的偏移量。 |
span | number | 规定列组应该横跨的列数。 |
valign | top middle bottom baseline | HTML5 不支持。定义在列组合中内容的垂直对齐方式。 |
width | pixels % relative_length | HTML5 不支持 |