Sometimes, Markdown content requires adding styles such as CSS attributes like color and font sizes and weight attributes.

However, Natively Markdown does not support CSS styles, the same also does not work in the readme.md files in Github or any markdown parsers.

There are multiple ways to achieve this.

Then, How to apply the color text to markdown content?

Markdown color content

color adds to markdown content in two ways

  • use inline HTML in markdown for styles

Since markdown convert to HTML code. Most of the markdown parsers support HTML code.

So, Write inline HTML code in markdown content. Added span tag with inline styles for changing color,font-weight, and font size.

Below html coded added to markdown files(.md extension)

<span style="color:green;font-weight:700;font-size:20px">
    markdown color font styles
</span>

And output you can see on the browser as below

markdown color font styles

Generated Output

<span style="color:green;font-weight:700;font-size:20px"> 
markdown color font styles
</span>
  • use CSS styles in markdown content

Another way using define CSS styles

  • Define CSS styles using selector as seen below
  • add content inside selector tags
<style>
red { color: red }
yellow { color: yellow }
</style>

<red> red color markdown text</red>
<yellow> red color markdown text</yellow>

Generated html

<p><red> red color markdown text</red>
<yellow> red color markdown text</yellow></p>

You can see the content styled in the browser as

red color markdown text red color markdown text

My Bold Text, in red color.{: style=“color: red; opacity: 0.80;” }

The above two ways work with almost all markdown parsers.

However, there are other ways we can do with different syntax with markdown content in Kramdown and Jekyll.