Skip to content
Related Articles

Related Articles

Improve Article

HTML DOM createHTMLDocument() Method

  • Last Updated : 24 Jul, 2020

The DOMImplementation createHTMLDocument() method is used to create a new HTML Document.


newDoc = document.implementation.createHTMLDocument(title);


  • title (Optional): It is a DOMString containing the title to be used for the new HTML document.

Return Value: This function returns Created HTML Document.

Example: In this example, we will create an HTML document using this method.

    <meta charset="UTF-8">
    <title>createHTMLDocument() method</title>
<body style="text-align:center;">
    <h1 style="color:green;">  
    <p id="a"
    HTML | DOM createHTMLDocument() method
    <button onclick = "Geeks()">
    Click Here
        function Geeks(){
            var doc = 
document.implementation.createHTMLDocument("New Document");
            var p = doc.createElement("p");
            p.innerHTML = "GeeksforGeeks";


Before Button Click:

After Button Click: Created document can be seen in the console.

Supported Browsers:

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

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :