How does Facebook write colorfully in the browser's console?

6

I need to do something like the image below:

You can see it when you enter the browser console by accessing any Facebook page.

I tried to insert HTML into the console.log() function, but it was in vain. Any tips?

    
asked by anonymous 30.11.2017 / 21:56

2 answers

5

You can do this:

console.log('%c Espere!', 'color: red; font-size: 20px;');

It's in the second parameter that you put the styles you want.

    
30.11.2017 / 22:10
2

You get this feature with the syntax below, where %c enables CSS styles for the message:

console.log('%c Olá!', 'color: red; font-size: 30px;');

  

ItdoesnotworkinIEandEdge(inthecaseofFacebook,the"alert" message presented in the question does not even appear in these browsers).

    
30.11.2017 / 22:14