Markdown Toolbox Logo Markdown Toolbox

Home
Blog

Affiliate Link

Fitness on Amazon for the new year

This is Amazon's fitness section. I'm not big on a gym membership but I like equipment for home.

How do I Merge Table Cells in Markdown?

Thursday, December 7, 2023

In standard Markdown, there's no built-in syntax to merge table cells. However, you can achieve cell merging by using HTML tables within your Markdown document.

Here's how you can merge table cells in Markdown:

  1. Create a table using HTML table tags (<table>, <tr>, <td>).
  2. Use the rowspan or colspan attribute in the <td> or <th> tag to merge cells vertically or horizontally.

Example of merging cells horizontally:

<table>
    <tr>
        <td colspan="2">Merged Header</td>
    </tr>
    <tr>
        <td>Cell 1</td>
        <td>Cell 2</td>
    </tr>
</table>

This creates a table where the first row has a single header cell that spans two columns.

Example of merging cells vertically:

<table>
    <tr>
        <td rowspan="2">Merged Cell</td>
        <td>Cell 1</td>
    </tr>
    <tr>
        <td>Cell 2</td>
    </tr>
</table>

In this example, the first column's cell spans two rows.

Note that while this method provides more flexibility in table formatting, not all Markdown renderers support HTML, and the appearance can vary depending on the platform's styling.