This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The DocumentType interface represents a Node containing a doctype.
Inherits properties from its parent, Node.
DocumentType.name Read only
The type of the document. It is always "html" for HTML documents, but will vary for XML documents.
DocumentType.publicId Read only
A string with an identifier of the type of document. Empty if the doctype given specifies no public ID.
DocumentType.systemId Read only
A string containing the URL to the associated DTD. Empty if the doctype given specifies no system ID.
Inherits methods from its parent, Node.
DocumentType.after()Inserts a set of Node objects or strings in the children list of the object's parent, just after this node.
DocumentType.before()Inserts a set of Node objects or strings in the children list of the object's parent, just before this node.
DocumentType.remove()Removes this object from its parent children list.
DocumentType.replaceWith()Replaces the document type with a set of given nodes.
| Specification |
|---|
| DOM> # interface-documenttype> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
DocumentType |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
after |
54 | 17 | 49 | 39 | 10 | 54 | 49 | 41 | 10 | 6.0 | 54 | 10 |
before |
54 | 17 | 49 | 39 | 10 | 54 | 49 | 41 | 10 | 6.0 | 54 | 10 |
name |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
publicId |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
remove |
24 | 12 | 23 | 15 | 7 | 25 | 23 | 14 | 7 | 1.5 | 4.4 | 7 |
replaceWith |
54 | 17 | 49 | 39 | 10 | 54 | 49 | 41 | 10 | 6.0 | 54 | 10 |
systemId |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
DOMImplementation.createDocumentType() to create a new DocumentType node.
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DocumentType