Markdown tables

A Markdown table is rows of cells separated by pipes (|), with a row of dashes under the header. Tables come from GitHub-flavoured Markdown and work on GitHub, GitLab, in Hashlite and in most modern editors.

Basic syntax

Markdown
| Name  | Role     |
| ----- | -------- |
| Ada   | Engineer |
| Grace | Admiral  |
Result
Name Role
Ada Engineer
Grace Admiral
  • The first row is the header. It is required.
  • The second row is the delimiter row: at least one dash per column (three is common). It needs the same number of cells as the header.
  • The pipes at the start and end of a row are optional, and the columns do not have to line up.
  • Leave a blank line before and after the table.

Column alignment

Colons in the delimiter row set the alignment: :--- left, :---: center, ---: right. Right-align columns of numbers so the digits line up.

Markdown
| Item   | Qty | Price |
| :----- | :-: | ----: |
| Coffee |  2  |  3.50 |
| Bagel  |  1  | 12.25 |
Result
Item Qty Price
Coffee 2 3.50
Bagel 1 12.25

Formatting inside cells

Inline Markdown works in cells: bold, italic, code, links and images. Block elements such as lists, headings and code blocks do not.

Markdown
| Feature   | Status        |
| --------- | ------------- |
| **Login** | ~~Beta~~ Done |
| `export`  | [Docs](/guide) |
Result
Feature Status
Login Beta Done
export Docs

Escaping pipes

A pipe inside a cell ends the cell. Write \| to show a literal pipe; this also works inside inline code.

Markdown
| Operator | Meaning     |
| -------- | ----------- |
| `a \|\| b` | logical OR  |
| x \| y    | a pipe      |
Result
Operator Meaning
a || b logical OR
x | y a pipe

Line breaks in a cell

Each row must stay on one line. For a line break inside a cell, use the HTML tag <br>.

Markdown
| Step | Notes                        |
| ---- | ---------------------------- |
| 1    | Install<br>Then restart      |
Result
Step Notes
1 Install
Then restart

Merged cells

Markdown has no syntax for merged cells. Where HTML is allowed (GitHub, Hashlite and most editors), write an HTML table and use colspan or rowspan.

Markdown
<table>
  <tr><th>Quarter</th><th colspan="2">Sales</th></tr>
  <tr><td rowspan="2">Q1</td><td>Jan</td><td>120</td></tr>
  <tr><td>Feb</td><td>135</td></tr>
</table>
Result
QuarterSales
Q1Jan120
Feb135

Tips

  • Don't align by hand. Spacing is ignored, so only line columns up if it helps you read the source.
  • No header wanted? Leave the header cells empty: | | | followed by |---|---|.
  • Keep cells short. Long text makes tables scroll on phones; put details in a list below the table.
  • Empty cell? Just leave it blank between two pipes. Missing cells at the end of a row are filled in as empty.

Try it in Hashlite: open the free editor and see the result as you type.