The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XMLdocuments. Objects in the DOM tree may be addressed and manipulated by using methods on the objects. The public interface of a DOM is specified in its application programming interface (API).
After the release of ECMAScript, W3C began work on a standardized DOM. The initial DOM standard, known as “DOM Level 1,” was recommended by W3C in late 1998. About the same time, Internet Explorer 5.0 shipped with limited support for DOM Level 1. DOM Level 1 provided a complete model for an entire HTML or XML document, including means to change any portion of the document. Non-conformant browsers such as Internet Explorer 4.x and Netscape 4.x were still widely used as late as 2000.
DOM Level 2 was published in late 2000. It introduced the “getElementById” function as well as an event model and support for XML namespaces and CSS. DOM Level 3, the current release of the DOM specification, published in April 2004, added support for XPathand keyboard event handling, as well as an interface for serializing documents as XML.
By 2005, large parts of W3C DOM were well-supported by common ECMAScript-enabled browsers, including Microsoft Internet Explorer version 6 (2001), Opera, Safari and Gecko-based browsers (like Mozilla, Firefox, SeaMonkey and Camino).
||This section may require copy editing for grammar, style, cohesion, tone, or spelling. You can assist by editing it. (September 2011)
When an HTML page is rendered in a browser, the browser parses the markup (e.g. HTML), downloaded from the web-server into an in-memory DOM. The DOM is used to construct additional internal structures used to display the page in the browser window.
The nodes of every document are organized in a tree structure, called the DOM tree. The topmost node in the DOM tree is theDocument object. Each node has zero or more children.
An example of a DOM tree is shown below:
|-> Element (<html>)
|-> Element (<body>)
|-> Element (<div>)
|-> text node
|-> text node
|-> Text Area
|-> Radio Button
|-> Check Box
Because DOM supports navigation in any direction (e.g., parent and previous sibling) and allows for arbitrary modifications, an implementation must at least buffer the document that has been read so far (or some parsed form of it).
Web browsers rely on layout engines to parse HTML into a DOM. Some layout engines such as Trident/MSHTML and Presto are associated primarily or exclusively with a particular browser such as Internet Explorer and Opera respectively. Others, such as WebKitand Gecko, are shared by a number of browsers, such as Google Chrome, Firefox and Safari. The different layout engines implement the DOM standards to varying degrees of compliance.