Creating tables in markdown
Creating tables in markdown is actually quite simple once you get the hang of it, and can be broken down into easy steps.
Building a basic table
Creating tables in markdown is actually pretty simple, and easily customizable. For the simplest 2x2 table we simply need to create our columns with |
and write whatever we want in them. Then we need to follow them by a row of empty columns with three dashes - this is what indicates to markdown this is supposed to be a table.
| col 1 | col 2 |
| ----- | ----- |
| one | two |
col 1 | col 2 |
---|---|
one | two |
Expanding your table
From there adding columns and rows should be self explanatory - just add them the same way as the others:
col 1 | col 2 | col 3 | col 4 | col 5 | col 6 | col 7 |
---|---|---|---|---|---|---|
one | two | three | four | five | six | seven |
more | a | b | c | d | e | f |
rows | a | b | c | d | e | f |
Styling your table
You can also style the table somewhat - the special row is used to align text with a colon :
, one on the left aligns text to left, one on the right aligns it to right and double colon centers the text.
column 1 | column 2 | column 3 |
---|---|---|
left | right | center |
x | x | x |
| column 1 | column 2 | column 3 |
| :------- | -------: | :------: |
| left | right | center |
| x | x | x |
The usual markdown styling also works in table cells without issues:
column 1 | column 2 | column 3 |
---|---|---|
left | right | |
x | x | x |
We can even try to do something fun like x's and o's:
| x | | o |
| --- | --- | --- |
| x | o | |
| | x | x |