HTML colspan 属性

前へ 全ての HTML 属性 次へ

定義と用法

colspan 属性は、結合するテーブルセルの列数を指定します。


適用

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

要素 属性
<td> colspan
<th> colspan

例s

Td の例

2 つの列を結合したテーブルセルを持つ HTML テーブル:

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$100</td>
  </tr>
  <tr>
    <td colspan="2">Sum: $180</td>
  </tr>
</table>
Try it Yourself ❯

Th の例

2 つの列を結合したヘッダセルを持つ HTML テーブル:

<table>
  <tr>
    <th colspan="2">Monthly Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>
Try it Yourself ❯

ブラウザ・サポート

colspan 属性は、要素ごとに以下のブラウザがサポートしています。

要素
td Yes Yes Yes Yes Yes
th Yes Yes Yes Yes Yes

前へ 全ての HTML 属性 次へ