- 16 Nov 2022
- 1 Minute zum Lesen
- Mitwirkende
- Drucken
- DunkelLicht
- pdf
How to center align the text in Markdown?
- Aktualisiert am 16 Nov 2022
- 1 Minute zum Lesen
- Mitwirkende
- Drucken
- DunkelLicht
- pdf
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.
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
Go to the desired article in the Knowledge base portal
Paste the below code in the desired location where you want the text to appear
<p style="text-align: center;">Text_content</p>
Replace the 'Text_content' with your desired text
For example:
<p style="text-align: center;">Sample text with center alignment</p>
- 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
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