How to Merge Cells in HTML Tables

The admin panel that you'll actually want to use. Try for free.

February 21, 2024

You can merge cells in an HTML table using the colspan attribute for horizontal merging and the rowspan attribute for vertical merging. You’ll probably also want to go past basic merging and learn about nested merges, grouping and spanning across the entire table. This post covers all this so keep reading to learn more.

What are colspan and rowspan in HTML?

Use the colspan attribute in a <td> or <th> tag to merge cells horizontally. The colspan value determines how many columns you should merge into a single cell. For vertical merging, apply the rowspan attribute, which specifies the number of rows to merge.

Horizontal merging with colspan

To span a header across three columns in a table, you can apply the colspan attribute like this:

<table border="1"> <tr> <th colspan="3">Header Spanning 3 Columns</th> </tr> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> </tr> </table>

You could ship faster.

Imagine the time you'd save if you never had to build another internal tool, write a SQL report, or manage another admin panel again. Basedash is built by internal tool builders, for internal tool builders. Our mission is to change the way developers work, so you can focus on building your product.

Vertical merging with rowspan

If you need a row label to span two rows, use the rowspan attribute as shown below:

<table border="1"> <tr> <td rowspan="2">Row Header</td> <td>Data 1</td> </tr> <tr> <td>Data 2</td> </tr> </table>

Combining colspan and rowspan

For more complex table structures, combine both colspan and rowspan attributes:

<table border="1"> <tr> <th colspan="2">Group Header</th> <th rowspan="2">Vertical Header</th> </tr> <tr> <td>Data 1</td> <td>Data 2</td> </tr> </table>

This example features a header spanning two columns and a vertical header spanning two rows, showcasing effective cell merging both horizontally and vertically.

TOC

What are `colspan` and `rowspan` in HTML?
Horizontal merging with `colspan`
Vertical merging with `rowspan`
Combining `colspan` and `rowspan`

February 21, 2024

You can merge cells in an HTML table using the colspan attribute for horizontal merging and the rowspan attribute for vertical merging. You’ll probably also want to go past basic merging and learn about nested merges, grouping and spanning across the entire table. This post covers all this so keep reading to learn more.

What are colspan and rowspan in HTML?

Use the colspan attribute in a <td> or <th> tag to merge cells horizontally. The colspan value determines how many columns you should merge into a single cell. For vertical merging, apply the rowspan attribute, which specifies the number of rows to merge.

Horizontal merging with colspan

To span a header across three columns in a table, you can apply the colspan attribute like this:

<table border="1"> <tr> <th colspan="3">Header Spanning 3 Columns</th> </tr> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> </tr> </table>

You could ship faster.

Imagine the time you'd save if you never had to build another internal tool, write a SQL report, or manage another admin panel again. Basedash is built by internal tool builders, for internal tool builders. Our mission is to change the way developers work, so you can focus on building your product.

Vertical merging with rowspan

If you need a row label to span two rows, use the rowspan attribute as shown below:

<table border="1"> <tr> <td rowspan="2">Row Header</td> <td>Data 1</td> </tr> <tr> <td>Data 2</td> </tr> </table>

Combining colspan and rowspan

For more complex table structures, combine both colspan and rowspan attributes:

<table border="1"> <tr> <th colspan="2">Group Header</th> <th rowspan="2">Vertical Header</th> </tr> <tr> <td>Data 1</td> <td>Data 2</td> </tr> </table>

This example features a header spanning two columns and a vertical header spanning two rows, showcasing effective cell merging both horizontally and vertically.

February 21, 2024

You can merge cells in an HTML table using the colspan attribute for horizontal merging and the rowspan attribute for vertical merging. You’ll probably also want to go past basic merging and learn about nested merges, grouping and spanning across the entire table. This post covers all this so keep reading to learn more.

What are colspan and rowspan in HTML?

Use the colspan attribute in a <td> or <th> tag to merge cells horizontally. The colspan value determines how many columns you should merge into a single cell. For vertical merging, apply the rowspan attribute, which specifies the number of rows to merge.

Horizontal merging with colspan

To span a header across three columns in a table, you can apply the colspan attribute like this:

<table border="1"> <tr> <th colspan="3">Header Spanning 3 Columns</th> </tr> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> </tr> </table>

You could ship faster.

Imagine the time you'd save if you never had to build another internal tool, write a SQL report, or manage another admin panel again. Basedash is built by internal tool builders, for internal tool builders. Our mission is to change the way developers work, so you can focus on building your product.

Vertical merging with rowspan

If you need a row label to span two rows, use the rowspan attribute as shown below:

<table border="1"> <tr> <td rowspan="2">Row Header</td> <td>Data 1</td> </tr> <tr> <td>Data 2</td> </tr> </table>

Combining colspan and rowspan

For more complex table structures, combine both colspan and rowspan attributes:

<table border="1"> <tr> <th colspan="2">Group Header</th> <th rowspan="2">Vertical Header</th> </tr> <tr> <td>Data 1</td> <td>Data 2</td> </tr> </table>

This example features a header spanning two columns and a vertical header spanning two rows, showcasing effective cell merging both horizontally and vertically.

What is Basedash?

What is Basedash?

What is Basedash?

Ship faster, worry less with Basedash

Ship faster, worry less with Basedash

Ship faster, worry less with Basedash

You're busy enough with product work to be weighed down building, maintaining, scoping and developing internal apps and admin panels. Forget all of that, and give your team the admin panel that you don't have to build. Launch in less time than it takes to run a standup.

You're busy enough with product work to be weighed down building, maintaining, scoping and developing internal apps and admin panels. Forget all of that, and give your team the admin panel that you don't have to build. Launch in less time than it takes to run a standup.

You're busy enough with product work to be weighed down building, maintaining, scoping and developing internal apps and admin panels. Forget all of that, and give your team the admin panel that you don't have to build. Launch in less time than it takes to run a standup.

Dashboards and charts

Edit data, create records, oversee how your product is running without the need to build or manage custom software.

USER CRM

ADMIN PANEL

SQL COMPOSER WITH AI

Screenshot of a users table in a database. The interface is very data-dense with information.