I have a README.md
file for my project underscore-cli, a pretty sweet tool for hacking JSON and JS on the command-line.
I want to document the -
It's worth mentioning that you can add some colour in a README using a placeholder image service. For example if you wanted to provide a list of colours for reference:
- ![#f03c15](https://via.placeholder.com/15/f03c15/000000?text=+) `#f03c15`
- ![#c5f015](https://via.placeholder.com/15/c5f015/000000?text=+) `#c5f015`
- ![#1589F0](https://via.placeholder.com/15/1589F0/000000?text=+) `#1589F0`
Produces:
#f03c15
#c5f015
#1589F0
Here is the code you can write color texts
<h3 style="color:#ff0000">Danger</h3>
I'm inclined to agree with Qwertman that it's not currently possible to specify color for text in GitHub markdown, at least not through HTML.
GitHub does allow some HTML elements and attributes, but only certain ones (see their documentation about their HTML sanitization). They do allow p
and div
tags, as well as color
attribute. However, when I tried using them in a markdown document on GitHub, it didn't work. I tried the following (among other variations), and they didn't work:
<p style='color:red'>This is some red text.</p>
<font color="red">This is some text!</font>
These are <b style='color:red'>red words</b>.
As Qwertman suggested, if you really must use color you could do it in a README.html and refer them to it.
You cannot color plain text in a GitHub README.md
file. You can however add color to code samples with the tags below.
To do this just add tags such as these samples to your README.md file:
```json // code for coloring ``` ```html // code for coloring ``` ```js // code for coloring ``` ```css // code for coloring ``` // etc.
No "pre" or "code" tags needed.
This is covered in the GitHub Markdown documentation (about half way down the page, there's an example using Ruby). GitHub uses Linguist to identify and highlight syntax - you can find a full list of supported languages (as well as their markdown keywords) over in the Linguist's YAML file.
You can use the diff
language tag to generate some colored text:
```diff
- text in red
+ text in green
! text in orange
# text in gray
@@ text in purple (and bold)@@
```
However, it adds it as a new line starting with either - + ! #
or starts and ends with @@
This issue was raised in github markup #369, but they haven't made any change in decision since then (2014).
As of writing, Github Markdown renders color codes like `#ffffff`
(note the backticks!) with a color preview. Just use a color code and surround it with backticks.
For example:
becomes