Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to center tables in a markdown file?

I have a table:

    | This | Is | A | Table |     | :--- | -- | - | ----: |     | foo  | ba | r | elbaT | 

I'd like the table to display in the center of my Markdown file instead of left-aligned. I am not trying to align text, but the entire table itself. Do I need to resort to HTML/CSS to achieve what I want?

This is for an Apiary.io project.

like image 884
Meredith Avatar asked Jun 09 '14 19:06

Meredith


People also ask

How do I align in Markdown?

Aligning text in native markdown is not possible. However, you can align the text using inline HTML tags. To justify, replace right with justify in the above. It works, but it breaks links like <div style="text-align: right"> [up](https://github.com/loretoparisi/CapsNet#CapsNet) </div> will be not rendered as a link.

Can you do tables in Markdown?

Markdown makes it simple to format text online, such as bold text, and links. You can even make tables with Markdown.

How do you center a table in code?

To center this table, you would need to add ;margin-left:auto;margin-right:auto; to the end of the style attribute in the <table> tag. The table tag would look like the following. Changing the style attribute in the <table> tag, as shown above, results in the table being centered on the web page, as shown below.


2 Answers

If you use the standard documentation, use the <center> tag like so.

Blueprint

FORMAT: 1A HOST: http://www.google.com  # Tables Notes API is a *short texts saving* service similar to its physical paper presence on your table.  <center>  | Tables   |      Are      |  Cool | |----------|:-------------:|------:| | col 1 is |  left-aligned | $1600 | | col 2 is |    centered   |   $12 | | col 3 is | right-aligned |    $1 |  </center>  # Group Notes  (...) 

Preview


If you use the ‘New Documentation’, it's not possible to center a table (since the table takes a full width of the column).

Preview

like image 120
Baggz Avatar answered Sep 20 '22 19:09

Baggz


It is simple. As you know the "|-|" is used for indicate the table and ":" is used for indicate the text alignment. If |:-| entered that is a right aligned text column. If |-:| entered that is a left aligned text and if |:-:| entered that is a centre aligned.

like image 35
yashod perera Avatar answered Sep 18 '22 19:09

yashod perera