I'm trying to help my colleagues by creating usefull and easy to read console messages. Therefore I dived into colorizing them based on how important the information is I want to convey. I got the basics already, like colorizing the whole line with
console.log('%cThis will be red', 'color: red')
But I wanted to take things one step further and highlight specific words with different colors. But I can't find a way colorize only a single word, without affecting the rest of the sentence.
I know about
console.log('%cThis will be red, %cbut this will be blue', 'color: red', 'color: blue')
but I want to just colorize a single keyword. Is it possible to reset the color at a specific position in the string? Can I scope the css to a specific part of the string?