You can use all Unicode characters and the escape characters \n and \t. An example:

document.getElementById("test").onclick = function() {
  alert(
    'This is an alert with basic formatting\n\n' 
    + "\t• list item 1\n" 
    + '\t• list item 2\n' 
    + '\t• list item 3\n\n' 
    + '▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬▬\n\n' 
    + 'Simple table\n\n' 
    + 'Char\t| Result\n' 
    + '\\n\t| line break\n' 
    + '\\t\t| tab space'
  );
}
<!DOCTYPE html>
<title>Alert formatting</title>
<meta charset=utf-8>
<button id=test>Click</button>

Result in Firefox:

You get the same look in almost all browsers.

Answer from fuxia on Stack Overflow
🌐
University of Washington
washington.edu › accesscomputing › webd2 › student › unit5 › module2 › lesson1.html
Lesson 1: Using JavaScript to Show an Alert
You will start by writing a simple ... text editor. Add the following JavaScript code to the <head> section of your web page: <script> function showAlert() { alert ("Hello world!"); } </script>...
Discussions

How do you change JavaScript alert title?

you can't. modern browsers will not allow you to change the alert for security reasons. if you need to set it for some reason, use a modal or some other way of letting the user know.

More on reddit.com
🌐 r/HTML
7
0
January 4, 2017
how do I call an alert(); to a javascript tag
William Bouknight is having issues with: A task has asked me to write a program inside a script tag that would open a alert(); that said warning!. I attempted the code and the box with ... More on teamtreehouse.com
🌐 teamtreehouse.com
4
April 9, 2017
Html tags in alert box? - JavaScript - SitePoint Forums | Web Development & Design Community
Hi all, I am running into problems with JS again :sick: The situation now is that I have a set of assesment quiz questions for my users and once they click ‘submit’, there will be a message box showing the results. Among wrong answers, I will want to include a link back to the relevant ... More on sitepoint.com
🌐 sitepoint.com
0
January 16, 2006
Who else thinks that javascript alert() is an annoying, lazy, and ugly way to notify me of something on your site.
In contemporary browsers, the main nuisance is that alert window is modal, and steals focus from other tabs. But there's a solution, I've come across: http://riddle.pl/-/greasemonkey/alert.hack.user.js More on reddit.com
🌐 r/programming
115
30
February 21, 2009
🌐
Team Treehouse
teamtreehouse.com › community › where-do-i-put-the-alert-command-in-javascript
where do i put the alert command in JavaScript (Example) | Treehouse Community
February 16, 2019 - Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today. Start your free trial ... I dont know what i am doing wrong!!! ... <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script src="scripts.js"></script> </script> alert("Warning"); </body> </html>
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-dom-window-alert-method
HTML DOM Window alert() Method - GeeksforGeeks
... <!DOCTYPE html> <html lang="en"> ... green;"> GeeksforGeeks </h1> <p> For displaying the alert message, double click the "Show Alert Message" button: </p> <button ondblclick="myalert()"> Show Alert Message </button> <script> ...
Published   July 11, 2025
🌐
TutorialsPoint
tutorialspoint.com › javascript-create-an-alert-on-clicking-an-html-button
JavaScript - Create an alert on clicking an HTML button
March 11, 2025 - Display the Alert: The alert function is a built-in JavaScript function that displays a pop-up message with the specified text. var pressedButton = document.getElementsByTagName("button")[0]; pressedButton.addEventListener("click", function (event) { alert("You have pressed the button..........") ...
🌐
W3Schools
w3schools.com › jsref › met_win_alert.asp
Window alert() Method
It prevents the user from accessing other parts of the page until the alert box is closed. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Find elsewhere
🌐
W3Schools
w3schools.com › js › js_popup.asp
JavaScript Popup Boxes
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... An alert box is often used if you want to make sure information comes through to the user.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › alert
Window: alert() method - Web APIs | MDN
window.alert() instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
🌐
Bootstrap
getbootstrap.com › docs › 4.0 › components › alerts
Alerts · Bootstrap
On the dismiss button, add the data-dismiss="alert" attribute, which triggers the JavaScript functionality. Be sure to use the <button> element with it for proper behavior across all devices.
🌐
Telerik
telerik.com › blogs › how-to-do-javascript-alerts-without-being-a-jerk
How To Do JavaScript Alerts Without Being A Jerk
May 27, 2021 - Nearly every JavaScript UI framework includes a modal window of some sort. These windows use div overlays to block interaction with the page. There are several reasons why these widgets are better than the browser's native alert... They do not lock the entire browser, only preventing interaction with the viewport ... Many jQuery libraries offer a modal window, including Kendo UI, Telerik HTML5 and JavaScript framework.
🌐
Team Treehouse
teamtreehouse.com › community › how-do-i-call-an-alert-to-a-javascript-tag
how do I call an alert(); to a javascript tag (Example) | Treehouse Community
April 9, 2017 - A task has asked me to write a program inside a script tag that would open a alert(); that said warning!. I attempted the code and the box with the message appeared now it says my script tag no longer works. ... <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script src="scripts.js"></script> <script> alert("Warning!"); </script> </body> </html>
🌐
SitePoint
sitepoint.com › javascript
Html tags in alert box? - JavaScript - SitePoint Forums | Web Development & Design Community
January 16, 2006 - Hi all, I am running into problems with JS again :sick: The situation now is that I have a set of assesment quiz questions for my users and once they click ‘submit’, there will be a message box showing the results. Among wrong answers, I will want to include a link back to the relevant ...
🌐
YouTube
youtube.com › watch
Using JavaScript to Show an Alert | JavaScript Tutorial - YouTube
Welcome to our YouTube channel! Are you interested in learning how to enhance your web development skills with JavaScript? In this tutorial, we will teach yo...
Published   June 21, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-design-a-custom-alert-box-using-javascript
How to Design a Custom Alert Box using JavaScript
July 23, 2025 - Create the HTML file with the basic structure including a button to trigger the custom alert box. Then import the SweetAlert2 library by adding the appropriate <link> tag in the <head> section of your HTML file for CSS, and <script> tag before the closing <body> tag for JavaScript...
🌐
Medium
medium.com › @python-javascript-php-html-css › recognizing-javascript-alert-pop-ups-limitations-for-extended-message-statements-bfe382c04a89
Recognizing JavaScript Alert Pop-ups’ Limitations for Extended Message Statements
October 2, 2024 - JavaScript alerts are simple pop-ups that show in the browser and cannot be customized. This implies that you are unable to add unique HTML components, such as images or links, or ...
🌐
YouTube
youtube.com › watch
How to do JavaScript Popups (alert, confirm, prompt examples) - YouTube
Learn how to alert, prompt, and confirm in JavaScript for explicit user input with a popup message box.00:00 Introduction00:58 JavaScript alert examples03:40...
Published   August 31, 2021
🌐
Herokuapp
testpages.herokuapp.com › styled › alerts › alert-test.html
Test Page For JavaScript Alerts
There are three main JavaScript methods which show alert dialogs: alert, confirm and prompt.