Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

Merging Cells: colspan and rowspan

Merging Cells: colspan and rowspan

~7 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026

Sometimes a single cell should stretch across multiple columns or rows - for example, a heading that sits above the entire table. There are two attributes for this: colspan and rowspan.

colspan: merging multiple columns

colspan="2" makes a cell take up the space of two columns (instead of just one):

<table>
  <tr>
    <th colspan="2">Matchday 1</th>
  </tr>
  <tr>
    <td>Home</td>
    <td>Away</td>
  </tr>
</table>

Important: since the first row only has one cell, but it takes up the space of two columns, you don't need to adjust anything in the second row - colspan automatically "uses up" the column slots for you.

rowspan: merging multiple rows

rowspan="2" works the same way, just vertically: the cell takes up the space of two rows:

<table>
  <tr>
    <th rowspan="2">Goalkeeper</th>
    <td>Player B</td>
  </tr>
  <tr>
    <td>Backup: Player C</td>
  </tr>
</table>

Here, the first row has two cells (one of them with rowspan="2"), but the second row only has a single one - since the goalkeeper cell already covers both rows, the second row doesn't need its own cell for it anymore.

Achtung: colspan and rowspan can be confusing at first, because you need to keep track of how much space the merged cells already take up when counting cells per row. It's best to test such tables step by step in your browser, instead of writing everything at once.

A small fixture table for Finn

Let's build a small table for the next match, where one heading spans two columns:

index.html
<h2>Next Game</h2>
<table>
  <tr>
    <th colspan="2">Saturday, 3pm</th>
  </tr>
  <tr>
    <td>Home</td>
    <td>Sample Town FC</td>
  </tr>
  <tr>
    <td>Away</td>
    <td>Example Village FC</td>
  </tr>
</table>

Tipp: Block complete! You can now build tables for almost any kind of tabular data - from simple lists to more complex overviews with merged cells.