Why styles are removed
A Markdown file can come from anyone. If it could use any HTML and CSS, a
README could cover the page, fake a login box, or hide text. So GitHub,
MarkdownPaper and most other apps allow only a safe set of HTML tags, and
style attributes are not on the list.
What works instead
Bold or italic for a word that must not be missed:
You write
The deadline is **Friday at noon**.You see
The deadline is Friday at noon.
A callout for a whole note or warning. GitHub and MarkdownPaper show these with a label and an icon:
You write
> [!WARNING]
> This deletes every file in the folder.You see
Warning
This deletes every file in the folder.
Highlight with <mark>, which most apps allow:
You write
Read the <mark>last paragraph</mark> before you sign.You see
Read the last paragraph before you sign.
A diff block for green and red lines, when showing what changed:
You write
```diff
+ Added: dark mode
- Removed: the old toolbar
```You see
+ Added: dark mode
- Removed: the old toolbarColors in GitHub issues
In GitHub issues, pull requests and discussions, a color code inside
backticks, like `#a74820`, shows a small swatch of that color next to
it. It shows the color, but does not color the text, and it does not work in
README files.
Where colored text does work
Apps that render Markdown without removing HTML styles will show them. That includes some static site generators and editors, but it is not portable: the same file loses its colors on GitHub. If color matters, Markdown is the wrong format for that part, and an exported HTML file or a document app is the better tool.
Questions
How do I make red text in Markdown?
Plain Markdown cannot. <span style="color: red">text</span> works only in
apps that keep HTML styles, which GitHub does not.
Can I color text in a GitHub README?
No. GitHub removes the style attribute. Use bold, a callout or a diff block
to draw attention instead.
How do I highlight text in Markdown?
Use <mark>text</mark>. See
Markdown text formatting for highlight
and other styles.
Next
- Markdown callouts and alerts, the most portable way to make something stand out.
- See what your Markdown really shows in the reader.