Skip to content
All Markdown syntax

Colored text in Markdown

Text

Markdown syntax

Needs HTML
<span style="color:#c9372c">red text</span>

Inline style. Stripped by GitHub and many hosted renderers.

There is no color in Markdown itself. Where inline HTML styles survive, a span with a color works; GitHub strips styles, so the usual workaround there is LaTeX's \color inside math.

All ways to write it

  • <span style="color:#c9372c">red text</span>
    Inline style. Stripped by GitHub and many hosted renderers.Needs HTML
  • $\color{red}{\text{red text}}$
    LaTeX color, in tools that render math (GitHub, Jupyter, KaTeX-based editors).Some tools only

Example

You type

$\color{green}{\text{Passing}}$ and $\color{red}{\text{Failing}}$

In a tool that renders math, this shows the two words in green and red. In one that doesn't, you see the raw LaTeX.

Questions

How do I color text in a GitHub README?

Inline styles are removed on GitHub. Use math: $\color{red}{\text{your text}}$. GitHub renders math with MathJax, which supports \color.

Can I highlight text in Markdown?

Some editors, including Obsidian, treat ==text== as a highlight. It is not part of CommonMark or GitHub Flavored Markdown; <mark>text</mark> is the HTML fallback.

Text color in Confluence

Confluence's editor has a text color menu, which is the simplest route on a page. Markdown Macro+ renders math with KaTeX, and KaTeX supports \color; check the result in the live preview before you save.

Related syntax

Also in Text

See all Markdown syntax