The Wayback Machine - https://web.archive.org/web/20240118180548/https://www.geeksforgeeks.org/how-to-create-a-dialog-box-or-window-in-html/
Open In App
Related Articles

How to create a dialog box or window in HTML ?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

In this article, we will create a dialog box or window using the <dialog> tag in the document. This tag is used to create popup dialog and models on a web page. This tag is new in HTML5.

Syntax:

<dialog open> Contents... </dialog>

Example 1:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to define a dialog 
        box or window?
    </title>
  
    <style>
        dialog {
            color: green;
            font-size: 30px;
            font-weight: bold;
            font-style: italic;
        }
  
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
    <h1>
        <dialog> tag
    </h1>
    <dialog open>
        Welcome to GeeksforGeeks
    </dialog>
</body>
  
</html>              


Output:
dialog tag

Example 2:




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="utf-8">
    <title>
        How to define a dialog
        box or window?
    </title>
  
    <style>
        table,
        th,
        td {
            border: 1px solid red;
        }
    </style>
</head>
  
<body>
    <center>
        <h2>GeeksForGeeks</h2>
        <h2>
            How to define a 
            dialog box or window
        </h2>
          
        <dialog open>
            This is an open dialog window
        </dialog>
    </center>
</body>
  
</html>


Output:

Supported Browsers are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 05 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials