Atributo HTML <th> colspan

❮ Etiqueta HTML <th>

Ejemplo

Una tabla HTML con una celda de encabezado que abarca dos columnas:

<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>

Definición y uso

El colspanatributo define el número de columnas que debe abarcar una celda de encabezado.


Compatibilidad con navegador

Attribute
colspan Yes Yes Yes Yes Yes

Nota: Solo Firefox admite colspan="0", que tiene un significado especial (consulte a continuación en la tabla "Valores de atributos").


Sintaxis

<th colspan="number">

Valores de atributo

Value Description
number Sets the number of columns a header cell should span. Note: colspan="0" tells the browser to span the cell to the last column of the column group (colgroup)

❮ Etiqueta HTML <th>