MDUtil

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.

Markdown
<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.

Markdown
<p align="center">
  <img src="/samples/landscape.svg" alt="Green hills under a blue sky" width="240">
</p>

Result

Green hills under a blue sky

Centered heading

Headings take the attribute too, as in the title block of many README files.

Markdown
<h1 align="center">Project name</h1>
<p align="center">A one-line description of the project.</p>

Result

Project name

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.

Markdown
<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.

Markdown
<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.

Markdown
| Name | Score |
| --- | :---: |
| Ana | 92 |
| Ben | 87 |

Result

NameScore
Ana92
Ben87

Badges in a row

Several images or links inside one centered paragraph line up in the middle.

Markdown
<p align="center">
  <img src="/samples/badge.svg" alt="Docs passing">
  <img src="/samples/badge.svg" alt="Docs passing">
</p>

Result

Docs passing Docs passing

Centering in popular apps

Which attribute works depends on how much HTML the app keeps.

AppSupportNotes
GitHub / GitLabDiffersalign="center" works; style attributes are removed.
VS Code / TyporaSupportedalign and style both work in the preview.
ObsidianSupportedalign and style both work in reading view.
NotionNot supportedNo centering for text; images can be aligned from their menu.
Discord / SlackNot supportedNo alignment; text always starts on the left.

Questions and answers

Is there a Markdown syntax for centering?

No. CommonMark and GitHub Flavored Markdown have no alignment syntax, except for table columns. Use HTML where it is allowed.

How do I center an image on GitHub?

Put it in a centered paragraph: <p align="center"><img src="image.png" alt="…" width="300"></p>.

Why doesn't style="text-align: center" work on GitHub?

GitHub removes style attributes for security. Use the align attribute, which it keeps.

Why is the Markdown inside my centered <div> shown as typed?

Leave a blank line after <div align="center"> and before </div>. Without them, the content counts as part of the HTML.

Can I use the <center> tag?

It still works in browsers, but it is obsolete HTML and some sites remove it. align="center" is the safer choice.

How do I center a whole README header?

Use a <div align="center"> holding the logo as <img>, a heading and badges, with blank lines inside if you mix in Markdown.