How to style console.log() in JavaScript
Hello Devs,
Is it possible to style console.log() in JavaScript ? Its YES.
Have you ever tried this ? If No, then lets do it together in these 2 simple steps.
- Add %c before the text you want to style.
- Insert one more argument in the console log function with the style you want to apply.
Do Checkout some of these examples:
console.log(`I LOVE 💜 %c${name}`, "color: green");
will produce
console.log(`I LOVE 💜 %c${name}`, "color: red; font-size: 50px");
will produce
console.log(`%cI LOVE 💜 %c${name}`, "color: red; font-size: 50px");
will produce
If you liked this, please let me know in the comment.
Thanks,
CapsCode