![]() |
To Add Colors to JavaScript Console Outputs, we have multiple approaches In this article, we will learn to Add colors to Javascript console outputs. Below are the approaches used to add Colors to JavaScript Console Outputs: Table of Content Approach 1: Using %CThe %c placeholder is a special syntax that enables the application of CSS styling to specified sections of the console output. It allows programmers to format console messages according to CSS principles, Syntax:console.log("%c GeeksforGeeks", "color:green;");
Example: In this example, we are using the above-explained approach. Javascript
Output: Approach 2: Using ANSI escape codeThe output color of the console can be modified via JavaScript using ANSI escape codes. Console messages can have their appearance changed to improve readability and visual distinctiveness by inserting escape sequences, such as ‘\x1b[36m%s\x1b[0m’ for Green color. Syntax:console.log('\x1b[36m%s\x1b[0m', 'GeeksforGeeks');
Example: In this example, we are using the above-explained approach to change our output color in the console. Javascript
Output: |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |