Markdown Merge Cells: What Works and What Does Not

How-to basics · Updated November 9, 2026

Markdown Merge Cells: What Works and What Does Not

No: standard Markdown tables do not support merged cells. If your Markdown renderer allows HTML, you may be able to use an HTML table with colspan or rowspan, but whether that works depends on the platform; otherwise, restructure the table or use another format.

What “merge cells” means in a table

Merging cells combines two or more neighboring cells into one larger cell. A cell that spans several columns can hold a heading across those columns; a cell that spans rows can group related entries vertically. In a spreadsheet, merging usually changes the grid itself. In a document, it changes how the table is laid out.

For example, imagine a table with quarterly sales grouped under the year 2026. A merged heading could stretch across the four columns for Q1, Q2, Q3, and Q4. In Markdown, you can write the words “2026” in a table cell, but the basic table syntax has no instruction to make that cell cover four columns.

This distinction matters because Markdown is a text format interpreted by a renderer. The text source describes a table using a limited set of markers; the renderer turns those markers into a visual table. A feature available in a particular renderer is not necessarily part of Markdown everywhere.

What standard Markdown tables can do

The original Markdown specification did not define table syntax. Many platforms later added tables as an extension. GitHub Flavored Markdown (GFM), for example, supports pipe tables, as do many other Markdown tools. These tables provide rows and columns, and the separator row can indicate left, center, or right alignment. They do not provide a standard way to merge cells.

A simple pipe table looks like this:

| Product | Price | Stock |
|:--------|------:|------:|
| Notebook | 4.50 | 18 |
| Pen | 1.25 | 42 |

Each row has values in corresponding columns. The separator line identifies the columns and can set their alignment, but it does not let a cell span multiple columns or rows. Adding extra pipes, leaving a cell blank, or changing the number of separators does not create a merged cell. Depending on the renderer, inconsistent rows may instead be repaired, displayed unexpectedly, or treated as malformed.

Why pipe tables do not have merged cells

Pipe tables are designed to be readable and editable as plain text. Their simple structure makes them convenient in source files, code repositories, notes, and documentation. A consistent row-and-column grid is relatively easy for both people and software to parse. Spanning cells complicate that grid: a renderer must determine which columns a cell covers, how later rows line up, and what to do when the source is incomplete.

That simplicity is useful for many data tables, where every row has the same fields. It is less suited to presentation-oriented layouts with grouped headings, nested headers, or cells that cover several rows. Markdown tables are therefore best thought of as a portable way to show straightforward tabular data, not as a complete page-layout system.

There is also no single universal Markdown renderer. A table extension supported by one website or application might not work in another. Even if a platform adds a spanning feature, its syntax may be specific to that platform rather than portable Markdown.

Using an HTML table as a workaround

HTML tables support cell spanning through the colspan and rowspan attributes. If the Markdown renderer permits raw HTML tables and does not remove those attributes, an HTML table can provide the layout you want. For example, a heading spanning four columns could be written as:

<table>
  <tr>
    <th colspan="4">2026 sales</th>
  </tr>
  <tr>
    <th>Q1</th>
    <th>Q2</th>
    <th>Q3</th>
    <th>Q4</th>
  </tr>
  <tr>
    <td>120</td>
    <td>135</td>
    <td>128</td>
    <td>150</td>
  </tr>
</table>

The value colspan="4" makes the first header cell cover four columns. A cell that needs to cover two rows could use rowspan="2". In a real table, make sure the cells remaining in each row line up with the columns not already covered by a span. Incorrect counts can produce a confusing or broken layout.

HTML is not automatically a reliable workaround everywhere. Some systems disable raw HTML, allow only selected tags, or sanitize attributes for security and consistency. A Markdown preview in an editor may also behave differently from the published page. Check the exact destination rather than assuming that HTML accepted locally will be accepted after publishing.

Check the renderer before choosing a solution

If you want to use HTML, first check the documentation for the site, editor, or static-site generator where the Markdown will appear. Search for its raw HTML policy and any specific table extensions. Then preview the rendered result in that same environment. If the table is important, verify the published page too, since a preview and the final rendering can have different rules.

  • GitHub-style pipe tables: use them for simple tables, but do not expect standard pipe syntax to merge cells.
  • HTML-enabled Markdown: test a small table with a span and confirm that the destination preserves it.
  • Restricted editors: if HTML is stripped or unsupported, use the editor’s own table tool or choose a format designed for complex tables.
  • Content that must travel: test the document in every important destination, because Markdown extensions and HTML policies vary.

Alternatives that often read better

A merged cell may look tidy, but it is not always the clearest way to organize information. If the purpose is to group columns, repeat the group name in each relevant column heading. If the purpose is to label a category shared by several rows, repeat the category in each row or separate the table into smaller tables with descriptive headings.

For example, instead of placing “2026” in a merged cell over four quarter columns, use headings such as “2026 Q1,” “2026 Q2,” “2026 Q3,” and “2026 Q4.” That uses more text but makes each column understandable on its own, including when a table is copied, sorted, or read by assistive technology. Another option is a short heading above the table: “Quarterly sales for 2026,” followed by a normal table with Q1 through Q4.

For complicated data, consider whether a table is the right structure at all. A list of records, a sequence of smaller tables, or a chart with an explanatory caption may communicate the relationships more clearly. If the document must preserve sophisticated table layout, an HTML page or a word-processing or publishing format may offer better control than portable Markdown.

Markdown tables versus spreadsheet cells

Markdown table syntax and spreadsheet table formatting are different things. In Excel, a user can select cells and use Home > Merge & Center to merge them. That is a spreadsheet command; it does not add merge instructions to a Markdown pipe table. When spreadsheet content is copied or exported as Markdown, the resulting format may not preserve merged-cell layout.

For data that will be sorted, filtered, or processed, merged spreadsheet cells can also make the structure harder to work with. A heading in a merged cell may not be repeated for every data row, while tools generally work best when each row is a complete record with a value in each relevant field. If the goal is only to make a heading look centered across several columns, a non-merged formatting option may be preferable in the spreadsheet, and a plain descriptive heading may be preferable in Markdown.

If a spreadsheet with merged cells must become Markdown, decide how the information should be represented rather than expecting the visual layout to transfer exactly. Repeat a group label where it is needed, add a sentence above the table, or redesign the columns so that each row stands on its own.

Common problems and misconceptions

  • Leaving cells blank is not merging. A blank cell occupies its own position in the grid. It may look like an empty area, but it does not join neighboring cells.
  • Alignment markers do not span columns. Colons in a Markdown separator row control alignment in renderers that support the syntax; they do not change cell size.
  • HTML support is not guaranteed. A renderer can accept Markdown while rejecting raw HTML or removing span attributes.
  • A visual preview is not proof of portability. The same source can render differently in another Markdown application, website, or export format.
  • “Markdown” does not name one identical feature set. CommonMark, GFM, and application-specific extensions have different capabilities. Check the format actually used by your destination.

When a table looks misaligned, check that every row has the intended number of cells and that literal pipe characters inside cell text are escaped or otherwise handled according to the renderer’s rules. Do not add cells or pipes to imitate a span; that usually changes the table’s structure rather than merging anything.

Frequently Asked Questions

Can I merge cells in a Markdown table?
No, not with standard Markdown pipe-table syntax. Use HTML if the renderer permits it, or reorganize the table so the relationship is clear without merged cells.

Does GitHub Markdown support merged cells?
GitHub Flavored Markdown pipe tables do not have a cell-merging syntax. GitHub supports some raw HTML, but HTML handling is subject to platform rules; test the exact table in the repository or page where it will be used.

Can I use colspan in Markdown?
colspan is an HTML attribute, not a Markdown table feature. It can work inside an HTML table when the Markdown destination allows the relevant HTML and attribute.

Can I merge rows as well as columns?
Standard Markdown tables support neither row spans nor column spans. In an allowed HTML table, rowspan can span rows and colspan can span columns, subject to the renderer’s restrictions.

Why does my merged table work in one editor but not another?
Markdown applications can use different table extensions and different policies for raw HTML. One may render an HTML span while another removes it, displays the markup as text, or sanitizes the attribute.

What is the most portable alternative?
Use an ordinary rectangular table with clear, self-contained headings. Repeat group labels or put a short heading above the table so the relationships remain understandable across renderers.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.