DEV Community

Ido Barnea
Ido Barnea

Posted on

Console.log with style

Ever wondered how do console messages get their colours and styles? Well, it is very simple.
All you have to do in your 'console.log' function is adding some styles.

How can you do it?

1st,

add the '%c' before your message, as so: console.log('%c my cool message');

2nd,

after adding %c at the beginning of the message, you now can add a second argument to the console.log function, which is the styles.
So, from a borring console.log('my cool message'); we go to:
console.log('%cmy cool message', 'color:cyan; font-size:24px;');
Before  / After

Top comments (0)