2024-08-12
Use colons :
in the separator line to center columns:
| Name | Age | Location |
|:----:|:---:|:--------:|
| John | 30 | USA |
| Jane | 25 | Canada |
Columns in Markdown tables can be aligned to the left, right, or center. The alignment of the columns is determined by the position of colons in the separator line.
To center a column, place colons on both sides of the dashes in the separator line.
Example:
| Name | Age | Location |
|:----:|:---:|:--------:|
| John | 30 | USA |
| Jane | 25 | Canada |
This will center the 'Name', 'Age', and 'Location' columns in the final rendered Markdown table.
You can combine different alignments as needed. For example, to left-align one column and center others:
| Name | Age | Location |
|:-----|:---:|:--------:|
| John | 30 | USA |
| Jane | 25 | Canada |
With this method, the 'Name' column will be left-aligned, while 'Age' and 'Location' will be centered.