Centering Text and Images in Markdown
Markdown has no alignment syntax, so centering is done with HTML: <p align="center">text</p>. This guide covers text, images and headings, and the one place Markdown aligns on its own: table columns.
Quick answer
How do you center text in Markdown?
Wrap the text in an HTML tag with align="center": <p align="center">Centered text</p>. It works on GitHub, which keeps the align attribute but removes style. Elsewhere, style="text-align: center" works too, where styles are allowed.
<p align="center">This line is centered.</p>Result
This line is centered.
Centering and alignment examples
All examples use the align attribute, which works on GitHub and in most Markdown previews.
Centered image
Put the image in a centered paragraph. Use an <img> tag so you can set the width too.
<p align="center">
<img src="/samples/landscape.svg" alt="Green hills under a blue sky" width="240">
</p>Result
Centered heading
Headings take the attribute too, as in the title block of many README files.
<h1 align="center">Project name</h1>
<p align="center">A one-line description of the project.</p>Result
A one-line description of the project.
Markdown inside a centered block
Wrap Markdown in a <div align="center"> and leave blank lines inside it, so the Markdown is still read.
<div align="center">
**Bold**, `code` and [links](https://example.com) still work here.
</div>Result
Bold, code and links still work here.
Right-aligned text
align="right" works the same way, for a signature or a date.
<p align="right">The editors, October 2026</p>Result
The editors, October 2026
Centered table columns
Tables are the one place Markdown aligns by itself: colons in the dash row center a column.
| Name | Score |
| --- | :---: |
| Ana | 92 |
| Ben | 87 |Result
| Name | Score |
|---|---|
| Ana | 92 |
| Ben | 87 |
Badges in a row
Several images or links inside one centered paragraph line up in the middle.
<p align="center">
<img src="/samples/badge.svg" alt="Docs passing">
<img src="/samples/badge.svg" alt="Docs passing">
</p>Result
Centering in popular apps
Which attribute works depends on how much HTML the app keeps.
| App | Support | Notes |
|---|---|---|
| GitHub / GitLab | Differs | align="center" works; style attributes are removed. |
| VS Code / Typora | Supported | align and style both work in the preview. |
| Obsidian | Supported | align and style both work in reading view. |
| Notion | Not supported | No centering for text; images can be aligned from their menu. |
| Discord / Slack | Not supported | No alignment; text always starts on the left. |
Questions and answers
Is there a Markdown syntax for centering?
How do I center an image on GitHub?
<p align="center"><img src="image.png" alt="…" width="300"></p>.Why doesn't style="text-align: center" work on GitHub?
style="text-align: center" work on GitHub?style attributes for security. Use the align attribute, which it keeps.Why is the Markdown inside my centered <div> shown as typed?
<div> shown as typed?<div align="center"> and before </div>. Without them, the content counts as part of the HTML.Can I use the <center> tag?
<center> tag?align="center" is the safer choice.How do I center a whole README header?
<div align="center"> holding the logo as <img>, a heading and badges, with blank lines inside if you mix in Markdown.