MDConverter
Universal In-Browser Converter
100% Client-Side Private

How to Color, Center and Align Text in Markdown

By the MDConverter team · Updated · 2 min read

Quick answer

Markdown has no syntax for text color or alignment — it only describes structure. Where HTML is allowed you can use <span style="color:…"> and <p align="center">, but GitHub strips style attributes, so on GitHub color is only possible through LaTeX math ($\color{red}{\text{red}}$) and centering through the align attribute. Chat apps such as Discord offer workarounds like ANSI-colored code blocks.

Color with HTML (renderers that allow inline styles)

VS Code's preview, MkDocs, Hugo, Jekyll, Docusaurus, Obsidian and many static sites keep inline styles:

Markdown
This is <span style="color:#dc2626">red text</span> and this is <span style="color:#2563eb">blue text</span>.
Result

This is red text and this is blue text.

Pick colors with enough contrast against both light and dark themes, or the text may become unreadable for some readers.

Color on GitHub

GitHub removes style attributes and the old <font color> tag, so neither of the above works in READMEs. The options that do:

  1. LaTeX math: $\color{red}{\text{Important}}$ renders red text inside GitHub's math support. It is rendered as math (slightly different font) and should be used sparingly.
  2. Color previews in issues and PRs: a color code in backticks — #2563eb, rgb(37, 99, 235) or hsl(…) — shows a small color swatch next to it (issues, pull requests and discussions only).
  3. Emoji and alerts: 🔴 🟢 or GitHub's > [!WARNING] alerts communicate status without color text.
  4. Images: a badge or SVG image for colored labels.

Centering text

On GitHub and in most renderers, wrap the content in an HTML block with align="center". Leave blank lines inside the block if you want Markdown processed within it.

Markdown
<p align="center">
  <b>Centered bold text</b><br>
  A second centered line
</p>
Result

Centered bold text
A second centered line

Where CSS is allowed, <div style="text-align:center"> is the modern equivalent. Use align="right" to right-align.

Centering in tables is different: use colons in the separator row (| :---: |) to center a column. MarkdownTables.com explains all the table alignment options.

App-specific options

  • Obsidian: HTML spans with style work in reading view; CSS snippets and highlight (==text==) are the usual approach. See text formatting.
  • Discord: no color syntax, but a code block with the ansi language accepts ANSI color codes — DiscordFonts.net has a Discord colored text generator that writes them for you.
  • Notion: colors are set in the editor (/red, /blue commands); Notion's Markdown export drops them.
  • Reddit, Slack: no colored text.

Color and alignment when converting

If you need colored or centered text in a finished document, convert the Markdown first and style it in the destination: Markdown to Word gives you real Word headings and paragraphs you can recolor with styles, and Markdown to PDF offers themes. Markdown to HTML keeps inline <span style> HTML as written.

Color and alignment by app

AppSupportedNotes
GitHubPartlyNo style; LaTeX \color{} for color, align attribute for centering.
GitLabPartlySimilar to GitHub; color chips for color codes in backticks.
VS Code, MkDocs, Hugo, JekyllYesInline HTML with style is kept.
ObsidianYesInline HTML styles and CSS snippets.
DiscordPartlyANSI colors inside ```ansi code blocks only.
Slack, RedditNoNo colored or centered text.

Common mistakes and how to fix them

ProblemFix
Colored span shows on my site but not on GitHubGitHub strips style. Use LaTeX color or an image.
Markdown inside a centered <div> is not formattedLeave a blank line after the opening tag and before the closing tag.
<center> does nothing<center> is obsolete and removed by many sanitizers; use align="center" or CSS.

Tools for this

Frequently Asked Questions

Frequently Asked Questions About Text color & alignment

Comprehensive answers to common technical, formatting, security, and compatibility questions.

Not with Markdown syntax. Use HTML (<span style="color:red">) in renderers that allow inline styles, LaTeX \color{} in GitHub math, or style the document after converting it to Word, PDF or HTML.

Sources

← All Markdown lessons · Markdown cheat sheet