Skip to content
Related Articles

Related Articles

Improve Article
HTML DOM createDocumentType() Method
  • Last Updated : 24 Jul, 2020

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.


var doctype = document.implementation.createDocumentType(qualifiedNameStr, publicId, systemId);


  • qualifiedNameStr: It is a DOMString containing the qualified name
  • publicId: 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.

    <meta charset="UTF-8">
    <title>createDocumentType() method</title>
<body style="text-align:center;">
    <h1 style="color:green;">  
    <p id="a"
    HTML | DOM createDocumentType() method
    <button onclick = "Geeks()">
    Click Here
        function Geeks(){
            var dt = 
'svg:svg', null, 
            var doc = document.implementation.createDocument (
            var head = document.createElementNS(
            head.setAttribute('id', 'headDoc');
            var body = document.createElementNS(
            body.setAttribute('id', 'bodyDoc');


Before Button Click:

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

Supported Browsers:

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :