HTML dialog tag

<dialog> tag in HTML

The <dialog> tag is used to create a dialog box.

The <dialog> element is used to represent the part of the web page, which is used to interact with the user to give a message or to get a reply.


open attribute in <dialog> tag

The open attribute is declared in a <dialog> tag to indicate that the element should be visible.

Example

Try Yourself

<dialog> tag with HTML <form> tag

In HTML <form> tag, method="dialog" value is used to automatically close the form when the submit button is pressed, but the <form> tag must be inside the <dialog> tag.

Example

Try Yourself

If you don't know javascript, please leave the below example. We will see it upcoming chapters.

Javascript to control the <dialog> tag

Using Javascript we can control the dialog box.

showModal() method is used to show the dialog box.

close() method is used to close the dialog box.

Example

Try Yourself