HTML DOM createDocument() Method Last Updated : 12 Jul, 2022 Comments Improve Suggest changes Like Article Like Report The DOMImplementation createDocument() method is used to create and return a Document. Syntax: var doc = document.implementation.createDocument(namespaceURI, qualifiedNameStr, docType); parameters: namespaceURI: It is a DOMString containing the namespace URI of the document to be created, or null if the document doesn't belong to one.qualifiedNameStr: It is a DOMString containing the qualified namedocType (Optional): It Is the Document type of the document to be created, the default value is null. Return Value: This function returns DOMDocument object on success. Example: In this example, we will create a document using this method. html <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>createDocument() method</title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <p id="a"> HTML | DOM createDocument() method </p> <button onclick = "Geeks()"> Click Here </button> <script> function Geeks(){ var doc = document.implementation.createDocument ( 'http://www.w3.org/1999/xhtml', 'html', null); var head = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'head'); head.setAttribute('id', 'headDoc'); doc.documentElement.appendChild(head); var body = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'body'); body.setAttribute('id', 'bodyDoc'); doc.documentElement.appendChild(body); console.log(doc) } </script> </body> </html> Output: Before Button Click: After Button Click: Supported Browsers: Google Chrome 1Edge 12Firefox 1Safari 1Opera 12.1Internet Explorer 9 Comment More infoAdvertise with us Next Article HTML DOM createDocument() Method T taran910 Follow Improve Article Tags : JavaScript Web Technologies HTML HTML-DOM Similar Reads HTML DOM createDocumentType() Method The DOMImplementation createDocumentType() method returns a Doctype object which can either be used with DOMImplementation createDocument() method for document creation or can be put into the document. Syntax: var doctype = document.implementation.createDocumentType(qualifiedNameStr, publicId, syste 1 min read HTML DOM createHTMLDocument() Method The DOMImplementation createHTMLDocument() method is used to create a new HTML Document. Syntax: newDoc = document.implementation.createHTMLDocument(title); Parameters: title (Optional): It is a DOMString containing the title to be used for the new HTML document. Return Value: This function returns 1 min read HTML DOM createDocumentFragment() Method The createDocumentFragment() method in HTML DOM is used to create the document fragment which is useful for changing the content of the document such as deleting, modifying, or adding a new node. This method creates the document fragment, then appends the elements of the document to the document fra 2 min read HTML DOM createAttribute() Method This createAttribute() method is used to create an attribute with the specified name and returns the attribute object. The attribute.value property is used to set the value of the attribute and the element.setAttribute() method is used to create a new attribute for an element. This method() contains 2 min read HTML | DOM Table createTFoot( ) Method The Table createTFoot() method is used for creating an empty <tfoot> element and adding it to the table. It does not create a new <tfoot> element if a <tfoot> element already exists. In such a case, the createTFoot() method returns the existing one. The <tfoot> element must h 2 min read Like