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
๐ŸŒ
Js
alertbox.js.org
AlertBox - A simple, beautiful, responsive, easy to use, customizable text for JavaScript's Alert Box.
alertbox.render({ alertIcon: 'success', title: 'Thank You!', message: 'AlertBox Popup Message', btnTitle: 'Ok', themeColor: '#000000' }); If you want a custom button colour, then you add this code
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ How-to-design-a-custom-alert-box-using-JavaScript
How to design a custom alert box using JavaScript?
So, to create a custom alert box we need to write code using HTML, CSS, and JavaScript. ... Create a script tag and link the jQuery file to the code so that we can use its methods. Create a division tag with an id named "ready". Inside the division tag create another division tag with the class ...
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_js_alert.asp
How To Create an Alert Message Box
Fullscreen Video Modal Boxes Delete Modal Timeline Scroll Indicator Progress Bars Skill Bar Range Sliders Color Picker Email Field Tooltips Display Element Hover Popups Collapsible Calendar HTML Includes To Do List Loaders Badges Star Rating User Rating Overlay Effect Contact Chips Cards Flip Card Profile Card Product Card Alerts Callout Notes Labels Ribbon Tag Cloud Circles Style HR Coupon List Group List Group with Badges List Without Bullets Responsive Text Cutout Text Glowing Text Fixed Footer Sticky Element Equal Height Clearfix Responsive Floats Snackbar Fullscreen Window Scroll Drawing
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-design-a-custom-alert-box-using-javascript
How to Design a Custom Alert Box using JavaScript ? - GeeksforGeeks
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 ...
๐ŸŒ
Snap! Forum
forum.snap.berkeley.edu โ€บ advanced topics
How can I make a custom javascript alert() box like the one in the snap website? - Advanced Topics - Snap! Forum
July 31, 2022 - Ik this is offtopic but I'm making a website and I want to make a custom alert box like the one in the snap website ex:
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ javascript โ€บ javascript customize alert box
How to Create Customized Alert Box in JavaScript | Delft Stack
February 2, 2024 - This article teaches you how to create a customized alert box using jQuery UI, SweetAlert2, and a custom alert function.
๐ŸŒ
Love2Dev
love2dev.com โ€บ blog โ€บ custom-javascript-alert
JavaScript Alert โš ๐Ÿ’€ Boxes & Customized Alert Banners ๐Ÿšฉ [Tutorial]
These native functions have been around forever and make prompting the user for input or just conveying a message simple. They also natively keep the user from doing anything else with the browser, which honestly causes me more frustration than I would like. The finally negative to these native JavaScript alert dialogs is they cannot be styled or customized.
Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-create-customizable-alerts-in-javascript
How to Create Customizable Alerts in JavaScript?
The important steps in making customized alert boxes include writing the HTML and CSS for the alert box itself and utilizing JavaScript to dynamically set the style attributes and content based on user input.
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Create Custom Alert Box in Javascript using SweetAlert JS - YouTube
In this video, you will learn how to create custom alert box in javascript using sweetalert JS. I hope you'll like the video and leave your feedback and sugg...
Published ย  October 11, 2019
๐ŸŒ
CodePen
codepen.io โ€บ nishanc โ€บ pen โ€บ NWWPdZE
Custom JS Alert
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
๐ŸŒ
CodePen
codepen.io โ€บ XemsDoom โ€บ pen โ€บ JjOBoG
Custom alert box
If you are completely insane, use this custom alert box. Uses a callback to simulate a blocking behavior. As written in the JS editor part, this is dan...
๐ŸŒ
YouTube
youtube.com โ€บ adam khoury
Custom Alert Box Programming JavaScript CSS HTML Tutorial - YouTube
JavaScript comes equipped with stock dialog boxes that work well enough for alerting, confirming, and prompting for values. But most of the top interactive w...
Published ย  February 15, 2014
Views ย  133K
๐ŸŒ
GitHub
github.com โ€บ surajaswal29 โ€บ custom-alert-box-plugin
GitHub - surajaswal29/custom-alert-box-plugin: Custom alert box using javaScript and css. This plugin will provide the functionality to customize the default JavaScript alert box. ยท GitHub
Custom alert box using javaScript and css. This plugin will provide the functionality to customize the default JavaScript alert box. - surajaswal29/custom-alert-box-plugin
Starred by 19 users
Forked by 3 users
Languages ย  JavaScript 42.4% | CSS 30.7% | HTML 26.9%
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Create Custom Alert Box using Javascript Tutorial - YouTube
Read the Description !!! *Source Code is In the Description This Video is about how to create custom alert box using javascript.*Source Code This Tutorial* :...
Published ย  October 28, 2024
Top answer
1 of 1
4

There were two main problems:

  1. You were creating the dialog <div /> but you weren't actually appending it to the document
  2. You were defining alert but you weren't actually calling it anywhere

I've fixed these two things in the below snippet:

function alert(title, content) {
  var alertContent = `
    <div class="modal__overlay verdana">
      <div class="modal__window">
        <div class="modal__titlebar">
          <span class="modal__title">${title}</span>                        
          <button class="modal__close">X</button>                    
        </div>                     
        <div class="modal__content">${content}</div>
      </div>
    </div>`
  var dialogBox = document.createElement("div");
  dialogBox.innerHTML = alertContent;
  document.body.appendChild(dialogBox); // actually append it
}

alert('hello', 'hello world'); // call it here
.verdana {
  font-family: Verdana;
}

.modal__overlay {
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000000000000000000;
}

.modal__window {
  max-width: 500px;
  background: #ffffff;
  border: 1px solid #ffffff;
  font-size: 16px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.25);
}

.modal__titlebar {
  height: 40px;
  background: #333333;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__title {
  margin-left: 15px;
  font-weight: bold;
  color: #eeeeee;
}

.modal__close {
  width: 40px;
  height: 40px;
  outline: none;
  border: none;
  background: transparent;
  color: #eeeeee;
  cursor: pointer;
}

.modal__close:active {
  transform: scale(0.9);
}

.modal__content {
  padding: 15px;
  font-size: 0.9em;
}

Two other things to consider:

  1. You don't need to use string concatenation when using template literals; you can simply embed the expression
  2. Window.alert is a predefined function which you are potentially shadowing with your own function; I'd recommend giving it a different name.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ create-custom-alert-box-javascript
How to Create Custom Alert Box in JavaScript
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
University of Washington
washington.edu โ€บ accesscomputing โ€บ webd2 โ€บ student โ€บ unit5 โ€บ module2 โ€บ lesson1.html
Using JavaScript to Show an Alert
In our earlier PHP example, we ... must start with a $, but that isn't the case in JavaScript. Take a look at the following example, which uses a variable named myText to customize the text that's displayed in the alert box....
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 2838437 โ€บ how-to-style-an-alert-box-in-javascript
How to style an alert box in javascript | Sololearn: Learn to code for FREE!
You can have a look at it: https://stackoverflow.com/questions/7853130/how-to-change-the-style-of-alert-box ... clement ndiok Sweet alert js library is best. (https://unpkg.com/sweetalert/dist/sweetalert.min.js) You can see here how to use: https://code.sololearn.com/W19U9nTWp4XF/?ref=app ... I แด€แด "Tษชแดแด‡" thanks for the feedback. ... clement ndiok you can use some alert libraries and also you can make your customized alerts using pure js and jQuery.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_popup.asp
JavaScript Popup Boxes
To display line breaks inside a popup box, use a back-slash followed by the character n. ... 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 ...