In this article, we will explore tables in Markdown. Specifically, we’ll look at how to create, format, and manipulate tables using the Markdown syntax. We’ll also delve into the nuances of different flavors of Markdown and their support for tables.

Note: Examples demonstrated in this guide are suited for GitHub-Flavored Markdown (GFM).

Table of Contents

Introduction to Markdown Tables

Markdown supports the generation of tables for representing structured data in a compact and readable format. This ability is crucial for documentation, READMEs, and other text which requires to convey data concisely.

Markdown table syntax is quite straightforward. A basic table is composed of a row of headers, followed by a divider line, and then the table’s rows:

| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1   | Cell 2   |
| Cell 3   | Cell 4   |

When rendered, the output will look like this:

Header 1 Header 2
Cell 1 Cell 2
Cell 3 Cell 4

Use our free tools to build Markdown tables

Generating Basic Tables

Generating tables in Markdown revolves around the use of pipes (|) and hyphens (-). The pipes create columns, while the hyphens define the headers from the cells beneath them.

Let’s look at an example for better understanding:

| Name    | Age |
| ------- | --- |
| Alice   | 23  |
| Bob     | 27  |

The table, once rendered, will look like this:

Name Age
Alice 23
Bob 27

Formatting Table Content

It?s possible to format the content of your markdown table cells just like any other text in Markdown. You can make text bold, italic, or monospaced, create links, and more.

| Command | Description |
| ---     | ---         |
| `git status` | _List all **new or modified** files_ |
| `git diff` | Show file differences that **haven't been** staged |

The formatted table will be as follows:

Command Description
git status List all new or modified files
git diff Show file differences that haven’t been staged

Cell Spanning

In traditional HTML tables, you have the capability to span cells across multiple rows or columns. However, in a Markdown table, each cell is discrete and can’t span across multiple rows or columns. This is part of Markdown’s design philosophy of being a simple syntax.

Handling Empty Cells

In Markdown, you can create an empty cell by having nothing between the pipe characters.

Example:

| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1   |          |
| Cell 3   | Cell 4   |

This will result in:

Header 1 Header 2
Cell 1  
Cell 3 Cell 4

The second cell in the first row of the table is empty.

Markdown tables are straightforward to construct and offer a flexible way to insert structured data into your documents. However, remember that these tables are designed to be simple, and lack many features found in typical spreadsheet software or HTML tables. If you want to build a Markdown table with a visual editor, check out our free Markdown table creator