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 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 createComment() Method The createComment() method is used to create a comment node with some specified text. This property is used to set a text value as a parameter that is of string type. Syntax:document.createComment( text )Parameters: This method accepts single parameter text which is optional. This parameter is used 2 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 createObjectURL() method The createObjectURL() method creates a DOMString containing a URL representing the object given in the parameter of the method. The new object URL represents the specified File object or Blob object. Note: The URL lifetime is tied to the document in which it was created and To release an object URL, 2 min read HTML DOM createRange() Method The createRange() method creates a new Range object for the document. Syntax: range = document.createRange(); Parameters: This method does not accept any parameters. Return Value: This method returns the created Range. Example: In this example, we will create a range using this method, a range shoul 1 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 HTML | DOM Table createCaption( ) Method The Table createCaption() method is used in a table to create <caption> which is empty. It doesn't work if there is already a <caption> element. In such a case, the createCaption() method returns the existing one.Syntax tableObject.createCaption()Return Value : The newly created (or an e 1 min read HTML | DOM Table createTHead() Method The Table createTHead() method is used for creating an empty <thead> element and adding it to the table. It does not create a new <thead> element if a <thead> element already exists. In such a case, the createThead() method returns the existing one . The <thead> element must 2 min read Like