span 属性は、<col>/<colgroup> 要素がまたがる列数を定義します。
span 属性は、以下の要素で使用することができます:
要素 | 属性 |
---|---|
<col> | span |
<colgroup> | span |
最初の 2 列の背景色を赤色にします:
<table>
<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>
Try it Yourself ❯
<colgroup> に span 属性を使用して、最初の 2 列の背景色を設定します:
<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>
Try it Yourself ❯
span
属性は、要素ごとに以下のブラウザがサポートしています。
要素 | |||||
---|---|---|---|---|---|
col | Yes | Yes | Yes | Yes | Yes |
colgroup | Yes | Yes | Yes | Yes | Yes |