A Modal Dialog is a UI element that is displayed on top of the current page, blocking any interaction with the underlying content. Modal dialogs are often used on websites to display important information, such as login forms, error messages, or confirmation messages.
To create a simple modal dialog with HTML and CSS, you can follow these steps:
- Create a new HTML file and add the following code:
HTML
span class="hljs-meta-keyword" style="animation: 0s ease 0s 1 Normal none running none; appearance: none; background: none 0% 0% / Auto repeat scroll padding-box border-box rgba(0, 0, 0, 0); border: 0px none rgb(25, 103, 210); clear: none; clip: auto; columns: auto; contain: none; container: none; content: normal; cursor: auto; cx: 0px; cy: 0px; d: none; direction: ltr; display: inline; fill: rgb(0, 0, 0); filter: none; flex: 0 1 auto; float: none; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-variation-settings: normal; font-weight: 700; gap: normal; hyphens: manual; inset: auto; isolation: auto; line-height: 18px; margin: 0px; marker: none; mask: none; offset: none 0px auto 0deg; opacity: 1; order: 0; outline: rgb(25, 103, 210) none 0px; padding: 0px; page: auto; perspective: none; position: static; quotes: auto; r: 0px; resize: none; rotate: none; rx: auto; ry: auto; scale: none; speak: normal; stroke: none; transform: none; transition: all 0s ease 0s; translate: none; visibility: visible; x: 0px; y: 0px; zoom: 1;">html>
html>
head>
title>My Simple Modal Dialogtitle>
head>
body>
button id="open-modal">Open Modalbutton>
div id="modal" class="hidden">
div class="modal-content">
h2>This is a modal dialogh2>
p>This is the content of the modal dialog.