Displaying a Dialog Box in HTML

HTML provides the <dialog> element for displaying content in a dialog box (or modal window) that can also be made interactive, typically using JavaScript. The element takes the open attribute, which says to display the box and make it active. When the attribute is not specified, the box is not displayed. A form can also be integrated in the element, so that the form is displayed inside it. How to create forms is explained in Chapter 5. Figure 3.35 shows how the element is used, and Figure 3.36 depicts the result. The <button> element is used to display a button for the user to use to close the dialog box. However, scripting is needed to make it perform this function. The <button> element is also discussed further in Chapter 5.

In the example, what difference would it make if the message is not placed in a <p> element and when it is placed in a <div> element?

Source: Sklar David (2016), HTML: A Gentle Introduction to the Web’s Most Popular Language, O’Reilly Media; 1st edition.

Leave a Reply

Your email address will not be published. Required fields are marked *