W3Schools.com

DOM Document Object


Definition and Usage

The Document object is the root of a document tree.

The Document object gives us access to the document's data.

Since element nodes, text nodes, attributes, comments, etc. cannot exist outside the document, the Document object contains methods to create these objects. All Node objects have a ownerDocument property which associates them with the Document where they were created.

Note: The Document object can also use the properties and methods of the Node object.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The Document object is supported in all major browsers.


Document Object Properties

The "DOM" column indicates in which DOM Level the property was introduced.

Property Description DOM
doctype Returns the Document Type Declaration associated with the document 1
documentElement Returns the Document Element of the document (the HTML element) 1
documentURI Sets or returns the location of the document 3
domConfig Returns the configuration used when normalizeDocument() is invoked 3
implementation Returns the DOMImplementation object that handles this document 1
inputEncoding Returns the encoding, character set, used for the document 3
strictErrorChecking Sets or returns whether error-checking is enforced or not 3
xmlEncoding Returns the XML encoding of the XML document 3
xmlStandalone Sets or returns whether the XML document is standalone or not 3
xmlVersion Sets or returns the XML version of the XML document 3

Document Object Methods

The "DOM" column indicates in which DOM Level the method was introduced.

Method Description DOM
adoptNode(node) Adopts a node from another document to this document. Returns the adopted node 3
createAttribute() Creates an attribute node 1
createAttributeNS(URI,name) Creates an attribute with the specified name and namspaceURI 2
createCDATASection() Creates a CDATA node with the specified text. For XML DOM only 1
createComment() Creates a Comment node with the specified text 1
createDocumentFragment() Creates an empty DocumentFragment node 1
createElement() Creates an Element node 1
createElementNS() Creates an element with the specified namespace 2
createEntityReference() Creates an EntityReference node. For XML DOM only 1
createProcessingInstruction() Creates an EntityReference node. For XML DOM only 1
createTextNode() Creates a Text node 1
getElementById() Returns the element that has the ID attribute with the specified value 2
getElementsByTagName() Returns a NodeList containing all elements with the specified tagname 1
getElementsByTagNameNS() Returns a NodeList containing all elements with the specified namespaceURI and tagname 2
importNode() Imports a node from another document 2
normalizeDocument() Removes empty Text nodes, and joins adjacent nodes 3
renameNode() Renames the specified node 3


WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE