HTML span 属性

前へ 全ての HTML 属性 次へ

定義と用法

span 属性は、<col>/<colgroup> 要素がまたがる列数を定義します。


適用

span 属性は、以下の要素で使用することができます:

要素 属性
<col> span
<colgroup> span

Col の例

最初の 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 の例

<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

前へ 全ての HTML 属性 次へ