Skip to main content

Command Palette

Search for a command to run...

How to style console.log();

Published
β€’2 min read
How to style console.log();
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

I guess that your first code of JS was

console.log('Hello World')

even, mine was the same 🀏 same

So, have you wondered about styling it? πŸ€”

nevermind...

I am going to take the Discord warning message into account as an example

Discord Console Warning Message

Discord warning msg

  • If you have ever opened developer tools in Discord, you will find this warning msg from Discord... Check it out right now if you haven't (and listennn, don't paste any malicious code there)
  • So let's recreate the same warning message
  • Write some necessary HTML to link a JS file to it
  • Create a JS file and name it whatever you want
  • Now follow the steps below
    console.log(text, styling)
    
    When you style there will be two things you need to take note of.
  • text - Every text message starts with a prefix - %c; and it is a very important thing and without it, styling will not apply to the text
  • styling - Simple CSS

Let's head up to the code,

console.log('%cHold Up', 'color: #404EED; font-size: 60px; font-weight: bold;-webkit-text-stroke: 1px black;');
console.log("%cIf someone told you to copy/paste something here you have an 11/10 chance you're being scammed", "color: black; font-size: 18px;")
console.log("%cPasting anything in here could give attackers access to your Discord account.", "color: red; font-size: 18px; font-weight: bold;")

So, found this simple? If not you can dive into comments to ask questions...

Why not share your styling to the console.log(), I am very excited to see yours

Make sure to subscribe to my YouTube Channel I regularly upload some amazing web development videos...

Your support gives me motivation πŸ’ͺ

More from this blog

D

Dhairya Shah

119 posts