How to Change Text Color in Markdown (GitHub, Obsidian, Jira, Discord)

Markdown has no color syntax. Here is what works on each platform: inline HTML, the GitHub math trick, Jira color tags, Discord ansi blocks, and what to do when styles are stripped.

Standard Markdown cannot set text color. Whether you get color depends on where the Markdown is rendered, because color comes from HTML, CSS, or a platform feature. This page lists what works where, so you can skip the trial and error.

Quick answer by platform

Platform Works? Method
Static site generators (Jekyll, Hugo, Nuxt Content, Docusaurus) Yes Inline HTML <span style="color:red">
Obsidian Yes Inline HTML <span style="color:red">
GitHub README, issues, comments No for HTML styles The math trick below, or diff blocks
GitLab Mostly no diff blocks; HTML styles are sanitized
Jira (legacy wiki markup) Yes {color:red}text{color}
Discord Code blocks only ansi fenced block
Slack No Use emoji or bold
Notion Yes, in the editor Use the color menu; pasted HTML styles are ignored
Confluence Yes, in the editor Text color toolbar

Method 1: inline HTML

If your renderer allows raw HTML and does not sanitize style attributes, this works:

<span style="color: red;">This text is red.</span>
<span style="color: #0066cc;">This text is blue.</span>

Use a span for part of a line. Hex codes, rgb() values and CSS color names all work. Make sure the text still has enough contrast on both light and dark backgrounds, since the color you pick is fixed.

The older <font color="red"> tag also renders in many places but is obsolete HTML. Prefer span.

Method 2: CSS classes (your own site)

If you control the stylesheet, give the span a class so you can change colors in one place and support dark mode:

<span class="note-warning">Check this setting first.</span>
.note-warning { color: #b45309; }
@media (prefers-color-scheme: dark) {
  .note-warning { color: #fbbf24; }
}

Method 3: GitHub

GitHub removes style and color attributes from Markdown, so Method 1 shows plain text. Options that do work:

Math expressions. GitHub renders LaTeX with $...$, and LaTeX has a \color command:

$\color{red}{\textsf{This text is red}}$

\textsf keeps the font from turning italic like math. It works in README files, issues and comments, but the text is rendered as math, so it will not be selectable the same way and long sentences wrap poorly. Use it for short labels.

Diff blocks. For red and green lines:

```diff
- removed
+ added
```

Alerts. GitHub supports > [!NOTE], > [!WARNING] and similar, which give colored callouts without any HTML. See our callouts and admonitions guide.

Method 4: Jira wiki markup

{color:red}This is red{color}
{color:#0066cc}This is blue{color}

If you write in Markdown and paste into Jira, the Markdown to Jira converter handles the rest of the syntax.

Method 5: Discord

Discord does not color normal messages, but it renders ANSI color codes inside an ansi code block on desktop and web:

```ansi
[2;31mred text[0m
[2;34mblue text[0m
```

Each [2;31m sequence must be preceded by an invisible ESC character (byte 27) that does not survive copying from a web page, so use the Discord Colored Text Generator, which puts the real character on your clipboard. See the Discord Markdown guide for what else Discord supports.

When none of this works

  • Your colors disappear after publishing. The platform sanitizes HTML. Test with the live preview editor, which renders raw HTML, then check the target platform's rules.
  • You need colored output in a PDF or email. Convert with Markdown to HTML or Markdown to Email HTML, which keep inline styles.
  • You only need emphasis. Bold, italics and strikethrough work everywhere and never get stripped. A colored emoji such as a red or green circle also survives almost any platform.