Advertisement
Home Open Editor ❯

HTML colspan Attribute

Example

<table>
  <tr>
    <th colspan="2">Heading</th>
  </tr>
  <tr>
    <td>Table data</td>
    <td>Table data</td>
  </tr>
  <tr>
    <td>Foot data</td>
    <td>Foot data</td>
  </tr>
</table>

Try this code ❯

Meaning

The colspan attribute takes a numeric value that specifies how many columns wide a cell should be.

This is useful for creating tables with cells of different widths.


Standard Syntax

<element colspan="number">


Applies to:

The colspan attribute can be used on the following element:

Element Attribute
<td> colspan
<th> colspan

Advertisement

Attribute Values

Value Description
number Specifies the number of columns respectively that the cell is to span.

More Examples

Example

<table>
  <tr>
    <th>Heading</th>
    <th>Heading</th>
  </tr>
  <tr>
    <td colspan="2">Table data</td>
  </tr>
  <tr>
    <td>Table data</td>
    <td>Table data</td>
  </tr>
</table>

Try this code ❯

Home Open Editor ❯
Advertisement