You may have seen websites where as soon as a visitor land on the webpage, they show an alert message as a way to promote some service or offer some sort of discount coupon. If you do care about user retention, then trust me that is really annoying and you should never do that
Showing a single sentence in the alert message is pretty straightforward, but to split a sentence into multiple lines, we have to make use of a template string. We just need to replace quotes with backticks and type a sentence with line breaks.
In the following example, we have a button element and upon click of that, we will show an alert message. Please have a look over the code example and the steps given below.
HTML & CSS
We have one button element and it has “Show Alert” as innerText.
We have done some basic styling using CSS and added the link to our style.css stylesheet inside the head element.