HTML DOM createDocumentType() Method Last Updated : 12 Jul, 2022 Comments Improve Suggest changes Like Article Like Report 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, systemId); Parameters: qualifiedNameStr: It is a DOMString containing the qualified namepublicId: It is a DOMString containing the PUBLIC identifier.systemId: It is a DOMString containing the SYSTEM identifiers. Return Value: This function returns DOMDocumentType node. Example: In this example, we will create a document type using this method. html </html> <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>createDocumentType() method</title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <p id="a"> HTML | DOM createDocumentType() method </p> <button onclick = "Geeks()"> Click Here </button> <script> function Geeks(){ var dt = document.implementation.createDocumentType( 'svg:svg', null, 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'); console.log(dt); var doc = document.implementation.createDocument ( 'http://www.w3.org/1999/xhtml', 'html', dt); 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: Created document and the doctype can be seen in the console. Supported Browsers: Google Chrome 1Edge 12Firefox 1Safari 1Opera 12.1Internet Explorer 9 Comment More infoAdvertise with us Next Article HTML DOM createDocumentType() Method T taran910 Follow Improve Article Tags : JavaScript Web Technologies HTML HTML-DOM Similar Reads HTML DOM createDocument() Method 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 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 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