How to Align Tables Left, Right, or Center in Markdown

Published Jun 21, 2022

How can we left-align, right-align, or center-align our table contents in a Markdown page?

Different applications have different defaults for table content alignment, but we can force each column to follow some specified alignment.

Left-align (:--)

We can left-align by adding :-- in the second row.

| Header 1 | Header 2 | Header 3 |
|:---------|:---------|:---------|
| 1        | 2        | 3        |
Header 1Header 2Header 3
123

Right-align (--:)

We can right-align by adding --: in the second row.

| Header 1 | Header 2 | Header 3 |
|---------:|---------:|---------:|
| 1        | 2        | 3        |
Header 1Header 2Header 3
123

Center-align (:-:)

We can center-align by adding :-: in the second row.

| Header 1 | Header 2 | Header 3 |
|:--------:|:--------:|:--------:|
| 1        | 2        | 3        |
Header 1Header 2Header 3
123

Mix and match. Since each cell has its own alignment specifier, we can use different alignments for each column.