createDocumentType (W3C DOM Core method)

Version Depr. Static
DOM2 No No
Browser support (more…)
IE7 FF1.5+ SA2+ OP9+
None Full Full Full


var doctype = document.implementation.createDocumentType(
    '-//W3C//DTD XHTML 1.0 Strict//EN',

var dom = document.implementation.createDocument
    ('', 'html', doctype);

The example above creates a DocumentType for XHTML 1.0 Strict, then passes it as the doctype argument to createDocument. That operation would create this skeleton document:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns=""></html>


name (DOMString) required

The qualified name 1 of the document type to be created.

publicId (DOMString) required

The public identifier of this document type.

systemId (DOMString) required

The system identifier of this document type.


Create an empty DocumentType node.

Entity declarations and notations are not made available, and entity reference expansions and default attribute additions don't occur. A created DocumentType has a null ownerDocument, until it's associated with a Document; the doctype cannot be appended to an existing document, it must be passed as the doctype argument to createDocument.

The DOM does not currently specify any way of populating the created node — additional entities and notations cannot be added.

Return value

The created document type


Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.5 2.0 3.0 1.3 2.0 3.0 9.0 9.5
None None None Full Full Full Buggy Full Full Full Full
DANGER: Crash bug in Safari 1.3

In Safari 1.3 this method crashes the browser, whatever the circumstances of its use.

Internet Explorer doesn't implement this method (it returns undefined; in Internet Explorer 5.5 in HTML the implementation object itself is undefined).


1 A qualified name is comprised of a local name, plus an optional prefix delimited with a colon, for example svg:rect.

User-contributed notes

There are no comments yet.

Related Products