The documentType type refers to the Document Type Description (DTD) of the HTML documents.

The documentType is not well supported in all web-browsers and can be read or used with Firefox, Opera, Safari. Its characteristics are:

  • nodeType :10
  • nodeName : name of the doctype
  • nodeValue : null
  • parentNode : Document
  • childNode : none

For browsers which support this entity, it will be stored in document.doctype object. The documentType has three objects: name, entities, and notation. The name is the name of the doctype and it is the text placed immediately after <!DOCTYPE>. The entities are NameNodeMap of entities described by the doctype. The notations are NameNodeMap notations described by doctype.

NOTE: The documents in browsers usually use XHTML or HTML doctype, the entities and notations are not used and are empty.

Example of the documentType type in DOM

<!DOCTYPE HTML PUBLIC “-//w3c//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

Alert(document.doctype.name); // outputs: HTML

 

›› go to examples ››