How to center align the text in Markdown?
  • 16 Nov 2022
  • 1 Minute à lire
  • Contributeurs
  • Sombre
    Lumière
  • PDF

How to center align the text in Markdown?

  • Sombre
    Lumière
  • PDF

There is no French content available for this article, You are viewing the fallback version (English).

Center-aligning content in your article is straightforward in the WYSIWYG editor with the 'Align center' option in the toolbar.
However, there is no option to center align the text in the Markdown toolbar.

Default alignment

The default alignment of all the text in the Markdown editor is Left alignment.

Follow the below workaround to center align the text in Markdown editor.


Solution

  1. Go to the desired article in the Knowledge base portal

  2. Paste the below code in the desired location where you want the text to appear
    <p style="text-align: center;">Text_content</p>

  3. Replace the 'Text_content' with your desired text

For example: <p style="text-align: center;">Sample text with center alignment</p>

  1. The output would be as below

"Sample text with center alignment"

You can add the basic text formatting such as bold, italic, and strikethrough using the usual syntax for the entire code.

For example,
***<p style="text-align: center;">Text with basic formatting applied</p>***

Output:

Text with basic formatting applied

How to 'Right align' text in Markdown editor?

If you want the text to be right aligned, use the below code
<p style="text-align: right;">Text_content</p>


Center align Headings in Markdown

You can also center-align Headings in your article by slightly altering the HTML code snippet.
Replace the <p>...</p> with <h2>...</h2>, <h3>...</h3>, or <h4>...</h4>

For example, To center align a H3
<h3 style="text-align: center;">H3 that is center aligned</h3>

Output:

H3 that is center aligned


Cet article vous a-t-il été utile ?