Loading tutorials
<dialog> element is the HTML element for a window that sits on top of the page: a confirmation prompt, a small form, a message that needs attention. Before it existed, developers built these from <div> elements, z-index, focus-trapping scripts, and ARIA attributes. This chapter covers what7 min read<dialog> element before. Here you will learn the two ways to open a dialog, what each one changes in the page, and how to choose betwee6 min readdialog element does nothing until something opens it. This chapter covers the three methods that change a dialog's state, the open property that reports it, and the errors you get when you call a method in the wrong state.5 min readshowModal(): the top layer and inertness of the rest of the page. It assumes you can open and close a dialog from JavaScript, as covered in the previous chapters. It also assumes you know basic CSS stacking (z-index, `positio7 min readcancel event fires, and what the close event tells you afterwards. It also covers how to intercept a close request and how to6 min read<dialog> with showModal() and close(), and that you know the close event. It also assumes you know how HTML forms submit and validate. Here you will learn how a form inside a dialog can close it and report which button the user pressed, with no c6 min read<dialog> with showModal(), show() and close(). It also assumes you know what autofocus does on a form control, and that you can read basic DOM event code. Here you will learn which element receives focus when a dialog opens, where focus goes wh6 min readshowModal() and close() from earlier chapters. Here you will learn what the browser styles by default, how to override it without breaking the open and closed states, and how to style 5 min readshowModal(), close it with close(), and listen for the close event. It also assumes you know what ::backdrop is. If returnValue is unfamiliar, review the chapter on form method="dialog" first.6 min read<dialog> opened with showModal() already does a lot of accessibility work for you. This chapter covers what the browser handles, what it leaves to you, and how to check the result. It assumes you know how to open and close a dialog, how form method="dialog" and returnValue work, and7 min readshowModal() and close it with close(). It also assumes you have styled dialog and ::backdrop as covered in earlier chapters. Here you will make the dialog and its backdrop fade7 min read<dialog>. It assumes you have read the earlier chapters on showModal(), form method="dialog", returnValue, the cancel and close events, and ::backdrop styling. For each pitfall you get the symptom, the cause, and a fix.7 min read