The alert box is a system object, and not subject to CSS. To do this style of thing you would need to create an HTML element and mimic the alert() functionality. The jQuery UI Dialogue does a lot of the work for you, working basically as I have described: Link.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#dialog" ).dialog();
  } );
  </script>
</head>
<body>
 
<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
 
 
</body>
</html>

Answer from PCasagrande on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ met_win_alert.asp
Window alert() Method
The alert() method displays an alert box with a message and an OK button.
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_js_alert.asp
How To Create an Alert Message Box
<div class="alert"> <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> This is an alert box. </div> If you want the ability to close the alert message, add a <span> element with an onclick attribute that says "when you click on me, hide my parent element" - which is the container <div> (class="alert"). Tip: Use the HTML entity "&times;" to create the letter "x".
๐ŸŒ
Bootstrap
getbootstrap.com โ€บ docs โ€บ 4.0 โ€บ components โ€บ alerts
Alerts ยท Bootstrap
Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success).
๐ŸŒ
OneCompiler
onecompiler.com โ€บ html โ€บ 3xfmfsrwk
html alert box - HTML - OneCompiler
The editor shows sample boilerplate code when you choose language as HTML.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_popup.asp
W3Schools.com
The window.alert() method can be written without the window prefix. ... A confirm box is often used if you want the user to verify or accept something.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ html โ€บ html-dom-window-alert-method
HTML DOM Window alert() Method - GeeksforGeeks
The alert() method in HTML and JavaScript is used to display an alert box with a specified message.
Published ย  July 11, 2025
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 41136691 โ€บ how-to-design-alert-box-in-html
How to design alert box in HTML
The javascript alert() is a system message box that will will block your page whilst it displays and will look different on different operating systems. What you are looking for is usually referred to as a dialog box or modal popup, these are ...
๐ŸŒ
SitePoint
sitepoint.com โ€บ javascript
Html tags in alert box?
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 ...
๐ŸŒ
SweetAlert2
sweetalert2.github.io
SweetAlert2
SweetAlert2 - a beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ javascript-making-an-alert-box-show-up-in-browser
Javascript - making an alert box show up in browser (Example) | Treehouse Community
September 8, 2015 - <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>JavaScript Basics</title> <script src="js/script.js"></script> </head> <body> </body> </html> Then script.js should look like... ... This should then bring up the alert box with kate inside it when you load the page.
๐ŸŒ
W3Schools
w3schools.com โ€บ JS โ€บ tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
๐ŸŒ
Ant Design
ant.design โ€บ components โ€บ alert
Alert - Ant Design
You can customize the semantic dom style of Alert by passing objects/functions through classNames and styles.
๐ŸŒ
Speckyboy
speckyboy.com โ€บ home โ€บ css โ€บ 10 free css & js notification alert code snippets
10 Free CSS & JS Notification Alert Code Snippets for Web Designers
February 5, 2025 - We've curated the CSS & JavaScript source code of our favorite notification messages, dialog boxes and alert windows. All free and offer plenty of options.
๐ŸŒ
Test Pages
testpages.eviltester.com โ€บ pages โ€บ basics โ€บ alerts-javascript
Alerts - JavaScript | Test Pages
Show alert box ยท The following button will display a confirm dialog when clicked. Show confirm box ยท The following button will display a prompt dialog when clicked.
๐ŸŒ
TutorialsTeacher
tutorialsteacher.com โ€บ javascript โ€บ display-popup-message-in-javascript
JavaScript Message Boxes: alert(), confirm(), prompt()
JavaScript provides built-in global functions to display popup message boxes for different purposes. alert(message): Display a popup box with the specified message with the OK button.
๐ŸŒ
Bootstrap
getbootstrap.com โ€บ docs โ€บ 5.0 โ€บ components โ€บ alerts
Alerts ยท Bootstrap v5.0
Alerts are available for any length of text, as well as an optional close button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-pop-an-alert-message-box-using-php
How to Pop an Alert Message Box using PHP? - GeeksforGeeks
July 12, 2025 - The alert message just like a pop-up window on the screen. Using this you can alert to the user with some information and message. PHP doesn't support alert message box because it is a server-side language but you can use JavaScript code within the PHP body to alert the message box on the screen.