Javascript Reference - HTML DOM doctype Property








The doctype property gets the doctype of the HTML document, as a DocumentType object.

Browser Support

doctype Yes Yes Yes Yes Yes

Syntax

document.doctype

Return Value

The document's doctype, as a DocumentType object.

Example

The following code shows how to get the doctype object of an HTML document.


<!DOCTYPE html>
<html>
<body>
<p id="demo">doctype name.</p>
<button onclick="myFunction()">test</button>
<!--  www. ja va 2s.  co  m-->
<script>
function myFunction()
{
    var x=document.getElementById("demo");
    x.innerHTML=document.doctype.name;
}
</script>
</body>
</html>

The code above is rendered as follows: