How to add Color to your code snippets using markdown

jimajs

Jima Victor

Posted on January 1, 2022

How to add Color to your code snippets using markdown

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πŸŽ‰πŸŽ‰πŸŽ‰..

πŸ’– πŸ’ͺ πŸ™… 🚩
jimajs
Jima Victor

Posted on January 1, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related