Skip to main content

HTML Guide

Table cell spans past the end of its row group established by a “tbody” element; clipped to the end of the row group.

A <td> or <th> element has a colspan attribute value that extends beyond the total number of columns defined in the <tbody> section.

HTML tables must have rows with a consistent number of columns within each <thead>, <tbody>, or <tfoot> group. If a cell uses the colspan attribute to span more columns than exist in the current row group, the table becomes semantically incorrect and fails validation.

Example of the Issue

<table>
  <tbody>
    <tr>
      <td>Cell 1</td>
      <td>Cell 2</td>
    </tr>
    <tr>
      <td colspan="3">Too wide</td>  <!-- Invalid: colspan="3" but only 2 columns in tbody -->
    </tr>
  </tbody>
</table>

How to Fix

Ensure that the maximum number of columns in any row (considering colspan) within a <tbody> does not exceed the columns defined by the longest row in that group.

Corrected Example

<table>
  <tbody>
    <tr>
      <td>Cell 1</td>
      <td>Cell 2</td>
      <td>Cell 3</td>
    </tr>
    <tr>
      <td colspan="3">Spans all columns</td>
    </tr>
  </tbody>
</table>

Or, if you only need two columns:

<table>
  <tbody>
    <tr>
      <td>Cell 1</td>
      <td>Cell 2</td>
    </tr>
    <tr>
      <td colspan="2">Spans two columns</td>
    </tr>
  </tbody>
</table>

Adjust the column count by either increasing the number of cells in each row or reducing the value of colspan as appropriate for your table structure.

Learn more:

Related W3C validator issues