Last updated 2022-09-23 22:03:31

How To Create A Table In Markdown

There are two ways to create a table in Markdown:

Markdown syntax

Some Markdown renderers do not support the Markdown table syntax.

The syntax for creating a table involves the use of | and - to mark out what looks like an actual table which is then rendered as an HTML table.

Here is an example:

01: | Fruit | Price | 02: | ----- | ----- | 03: | Apple | $12 | 04: | Mango | $14 |

Because this is Markdown syntax, the style of your table is at the mercy of the overall CSS your platform has in place.

To have a bit more control over the table styling you might want to use HTML instead.

HTML syntax

When you use the Markdown syntax above, the renderer converts it to HTML. One of the nice things about Markdown is the ability to write HTML and it will still be considered valid Markdown. This is because Markdown is considered a superset of HTML. With that being said it's generally a good idea to avoid excessive use of HTML within your Markdown document as it reduces readability.

Here is the table above expressed using HTML with the items in color.

01: <table> 02: <tr> 03: <th>Fruit</th> 04: <th>Price</th> 05: </tr> 06: <tr> 07: <td style="color:green">Apple</td> 08: <td>$12</td> 09: </tr> 10: <tr> 11: <td style="color:orange">Mango</td> 12: <td>$14</td> 13: </tr> 14: </table>
Fruit Price
Apple $12
Mango $14

Here is another article for you 😊 "Markdown: Add a blockquote"