Advertisement
728x90
You can add CSS styling to the console output using the CSS format content specifier %c. The console string message can be appended after the specifier and CSS style in another argument. Let's print the red color text using console.log and CSS specifier as below,
js
1console.log("%cThis is a red text", "color:red");It is also possible to add more styles for the content. For example, the font-size can be modified for the above text
js
1console.log(
2 "%cThis is a red text with bigger font",
3 "color:red; font-size:20px"
4 );Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 84
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
427of476