🖼️Modal Dialog
Also known as Modal, Dialog Box, Modal Window, Lightbox
A box on top of the page that blocks the rest until you answer.
Think of it like
It is like a teacher who stops the class. You must answer first. Then the class goes on.
Example
Leo presses Delete. A modal asks: Delete 3 photos? with Cancel and Delete buttons. The page behind is greyed out.
Why it matters
It asks for one choice at the right time. So a risky step is not taken by mistake.
Definition
Example code
html
<dialog id="confirm">
<p>Delete 3 photos?</p>
<button>Cancel</button> <button>Delete</button>
</dialog>Try it
Your files
- report.pdf
- notes.txt
- photo.jpg
Use it for a question that cannot be undone, and almost nothing else.
Open it, then try to press a file behind it. Escape is the way out of any layer.
Common mistake
Key takeaways
- 1Blocks the page. Answer first.
- 2Short and focused. One task or question.
- 3Easy to leave. Escape and Cancel.