How does Facebook write color on the browser console?

Asked

Viewed 306 times

6

I need to do something similar to the image below:

inserir a descrição da imagem aqui

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

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

2 answers

6


You can do it like this:

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

It is in the second parameter that you put the styles you want.

2

You can get this feature with the syntax below, where %c activates CSS styles to the message:

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

inserir a descrição da imagem aqui

Does not work in IE and Edge (in the case of Facebook, the "alert" message displayed in the question is not even displayed in these browsers).

  • But in IE and Edge by chance Facebook prints color?

  • 1

    @Jeffersonquesado No IE and Edge print nothing. Message does not appear.

  • This "no IE or Edge" detail would make your answer even better =]

  • 1

    @Jeffersonquesado Good idea. Obg!

  • I’m happy to help =D

  • Upgrade, Edge Chromium works perfectly..

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.