How to center text with Markdown?

KylianMbappe picture KylianMbappe · Nov 21, 2018 · Viewed 45.2k times · Source

How do you center an item with Markdown? I'm looking for a solution that works in Grav. I can't find anything on the internet, and I'm getting a bit frustrated.

Answer

Estevan Maito picture Estevan Maito · Nov 21, 2018

Markdown does not support this feature natively, but you can achieve this wrapping Markdown into HTML.

As a rule of thumb, most 'flavors' of Markdown will render this as centered text:

<p style="text-align: center;">Centered text</p>

Specifically for Grav, as their documentation states, you should do these following steps:

in your system configuration file user/config/system.yaml make sure to activate the markdown extra option:

pages:
  markdown:
    extra: true

in your wrapper tag make sure to add the parameter markdown="1" to activate processing of markdown content:

<div class="myWrapper" markdown="1">
# my markdown content

this content is wrapped into a div with class "myWrapper"
</div>