Markdown table

By xngo on June 14, 2019

The original Markdown specification from John Gruber doesn't provide any special syntax for tables. However, he provided a workaround. It is to use HTML code inside Markdown code. For example, to add an HTML table to a Markdown article:

This is a regular paragraph.
 
<table>
    <tr>
        <th>Header1</th> <th>Header2</th>
    </tr>
 
    <tr>
        <td>data1</td> <td>data2</td>
    </tr>
    <tr>
        <td>data3</td> <td>data4</td>
    </tr>
</table>
 
This is another regular paragraph.

This workaround defeats its philosophy: "make Markdown code easy to read for humans".

Other developpers have extended Markdown specification to also include table. The syntax looks like the followings:

| Header1 | Header2     |
| ------- | ----------- |
| data1   | data2       |
| data3   | data4       |

It will render as:

Markdown table

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.