Those special characters don't work in HTML, the literal text '\r\n' will be rendered in the browser.
Using the backtick `
character creates a Template String, which has a bit more 'syntactic sugar' and functionality than raw HTML text. It is a Javascript string and you can use JS special characters (e.g. \r\n
) inside it.
HTML uses character encodings instead, which look like this:
. This represents the \n
'newline' character, and will work in your example.