Markdown `native` text alignment

2019-01-10 21:51发布

问题:

Does markdown support native text-alignment without usage html + css?

回答1:

native markdown doesn't support text alignment without html + css.



回答2:

In order to center text in md files you can use the center tag like html tag:

<center>Centered text</center>


回答3:

It's hacky but if you're using GFM or some other MD syntax which supports building tables with pipes you can use the column alignment features:

|| <!-- empty table header -->
|:--:| <!-- table header/body separator with center formatting -->
| I'm centered! | <!-- cell gets column's alignment -->

This works in marked.



回答4:

I known this isn't markdown, but <p align="center"> worked for me, so if anyone figures out the markdown syntax instead I'll be happy to use that. Until then I'll use the HTML tag.



回答5:

In Github You need to write:

<p align="justify">
  Lorem ipsum
</p>


回答6:

For Markdown Extra you can use custom attributes:

# Example text {style=text-align:center}

This works for headers and blockquotes, but not for paragraphs, inline elements and code blocks.

A shorter version (but not supported in HTML 5):

# Example text {align=center}


回答7:

I was trying to center an image and none of the techniques suggested in answers here worked. A regular HTML <img> with inline CSS worked for me...

<img style="display: block; margin: auto;" alt="photo" src="{{ site.baseurl }}/images/image.jpg">

This is for a Jekyll blog hosted on GitHub



回答8:

For python markdown with attr_list extension the syntax is a little different:

{: #someid .someclass somekey='some value' }

Example:

[Click here](http://exmaple.com){: .btn .btn-primary }

Lead information paragraph
{: .lead }


回答9:

The div element has its own alignment attribute, align.

<div align="center">
  my text here.
</div>


回答10:

To center align, surround the text you wish to center align with arrows (-> <-) like so:

-> This is center aligned <-


标签: markdown