HTML span 屬性
定義和用法
span
屬性定義一個 <col>
或 <colgroup>
元素應跨越的列數。
適用範圍
span
屬性可用於以下元素
元素 | Attribute |
---|---|
<col> | span |
<colgroup> | span |
示例
Col 示例
在這裡,前兩列應為紅色背景
<table>
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</colgroup>
<tr>
<th>ISBN</th>
<th>標題</th>
<th>價格</th>
</tr>
<tr>
<td>3476896</td>
<td>我的第一個 HTML</td>
<td>$53</td>
</tr>
</table>
自己動手試一試 »
Colgroup 示例
使用 <colgroup> span 屬性設定前兩列的背景顏色
<table>
<colgroup span="2" style="background:red"></colgroup>
<tr>
<th>ISBN</th>
<th>標題</th>
<th>價格</th>
</tr>
<tr>
<td>3476896</td>
<td>我的第一個 HTML</td>
<td>$53</td>
</tr>
<tr>
<td>5869207</td>
<td>我的第一個 CSS</td>
<td>$49</td>
</tr>
</table>
自己動手試一試 »
瀏覽器支援
span
屬性對每個元素的瀏覽器支援如下
元素 | |||||
---|---|---|---|---|---|
col | 是 | 是 | 是 | 是 | 是 |
colgroup | 是 | 是 | 是 | 是 | 是 |