How to add Color to your code snippets using markdown
Jima Victor

Jima Victor @jimajs

About: Code lover, crafting cool stuff with JavaScript. Also, geeking out in articles for the tech community. 🚀

Joined:
Oct 13, 2021

How to add Color to your code snippets using markdown

Publish Date: Jan 1 '22
40 3

Which one of these look better?
this?👇

function printHello() {
 console.log("Hello"); // prints hello to the console..
}
Enter fullscreen mode Exit fullscreen mode

or this..👇

function printHello() {
 console.log("Hello"); // prints hello to the console..
}
Enter fullscreen mode Exit fullscreen mode

That's right! The code snippet with colors definitely looks better and there are many advantages of using this feature built into text editors.

This feature that enables us to add colors to our code is known as syntax highlighting and it makes it easier and more enjoyable to read and understand code.

How to add syntax hightlighting in markdown

This is actually very easy to implement. All you have to do is add the name of the the programming language after the backticks in your markdown editor.
like this👇


```javascript
function printHello() {
 console.log("Hello"); // prints hello to the console..
}
```


and viola! You're done!!

Make the world beautiful today by adding some color to it😊
Happy New Year Coders🎉🎉🎉..

Comments 3 total

  • Gus Pear 🍐
    Gus Pear 🍐Jan 5, 2023

    Thanks Jima!! That is going to be really helpful

    • Jima Victor
      Jima Victor Jan 7, 2023

      I'm glad you found it useful. Thanks for reading!

  • Hany Taha
    Hany TahaFeb 2, 2024

    Thanks. That was very useful.

Add comment