History
The history of the Document Object Model is intertwined with the history of the " browser wars" of the late 1990s between Netscape Navigator and Microsoft Internet Explorer, as well as with that ofdocument.formName.inputName
or document.forms elements /code>.
The Legacy DOM enabled client-side form validation and simple interface interactivity like creating tooltips
The tooltip, also known as infotip or hint, is a common graphical user interface (GUI) element in which, when hovering over a screen element or component, a text box displays information about that element, such as a description of a button's f ...
.
In 1997, Netscape and Microsoft released version 4.0 of Netscape Navigator and Internet Explorer respectively, adding support for Dynamic HTML (DHTML) functionality enabling changes to a loaded HTML document. DHTML required extensions to the rudimentary document object that was available in the Legacy DOM implementations. Although the Legacy DOM implementations were largely compatible since JScript was based on JavaScript, the DHTML DOM extensions were developed in parallel by each browser maker and remained incompatible. These versions of the DOM became known as the "Intermediate DOM".
After the standardization of ECMAScript
ECMAScript (; ES) is a JavaScript standard intended to ensure the interoperability of web pages across different browsers. It is standardized by Ecma International in the documenECMA-262
ECMAScript is commonly used for client-side scripting o ...
, the W3C
The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 and led by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working to ...
DOM Working Group began drafting a standard DOM specification. The completed specification, known as "DOM Level 1", became a W3C Recommendation in late 1998. By 2005, large parts of W3C DOM were well-supported by common ECMAScript-enabled browsers, including Internet Explorer 6 (from 2001), Opera
Opera is a form of theatre in which music is a fundamental component and dramatic roles are taken by singers. Such a "work" (the literal translation of the Italian word "opera") is typically a collaboration between a composer and a librett ...
, Safari
A safari (; ) is an overland journey to observe wild animals, especially in eastern or southern Africa. The so-called "Big Five" game animals of Africa – lion, leopard, rhinoceros, elephant, and Cape buffalo – particularly form an importa ...
and Gecko
Geckos are small, mostly carnivorous lizards that have a wide distribution, found on every continent except Antarctica. Belonging to the infraorder Gekkota, geckos are found in warm climates throughout the world. They range from .
Geckos ar ...
-based browsers (like Mozilla
Mozilla (stylized as moz://a) is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, spreads and supports Mozilla products, thereby promoting exclusively free software and open standards, wi ...
, Firefox, SeaMonkey and Camino
Camino may refer to:
Places
*Camino, California, United States, a census-designated place
*Camino, Piedmont, Italy, a town
* Camino, Veneto, Italy, a town
People
*Jaime Camino (1936–2015), Spanish film director and screenwriter
*Renae Camino ...
).
Standards
The W3C
The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 and led by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working to ...
DOM Working Group published its final recommendation and subsequently disbanded in 2004. Development efforts migrated to the WHATWG, which continues to maintain a living standard. In 2009, the Web Applications group reorganized DOM activities at the W3C. In 2013, due to a lack of progress and the impending release of HTML5, the DOM Level 4 specification was reassigned to the HTML Working Group
The HTML Working Group was an Internet Engineering Task Force (IETF) working group from 1994 to 1996, and a World Wide Web Consortium (W3C) working group from 1997 to 2015.
The working group was co-chaired by Paul Cotton, Sam Ruby, and Maciej ...
to expedite its completion. Meanwhile, in 2015, the Web Applications group was disbanded and DOM stewardship passed to the Web Platform group. Beginning with the publication of DOM Level 4 in 2015, the W3C creates new recommendations based on snapshots of the WHATWG standard.
* DOM Level 1 provided a complete model for an entire HTML or XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
document, including the means to change any portion of the document.
* DOM Level 2 was published in late 2000. It introduced the getElementById
function as well as an event model
In programming and software design, an event is an action or occurrence recognized by software, often originating asynchronously from the external environment, that may be handled by the software. Computer events can be generated or triggere ...
and support for XML namespaces and CSS.
* DOM Level 3, published in April 2004, added support for XPath and keyboard event handling
In programming and software design, an event is an action or occurrence recognized by software, often originating asynchronously from the external environment, that may be handled by the software. Computer events can be generated or triggere ...
, as well as an interface for serializing
In computing, serialization (or serialisation) is the process of translating a data structure or object state into a format that can be stored (e.g. files in secondary storage devices, data buffers in primary storage devices) or transmitted ( ...
documents as XML.
* DOM Level 4 was published in 2015. It is a snapshot of the WHATWG living standard.
Applications
Web browsers
To render a document such as a HTML page, most web browsers use an internal model similar to the DOM. The nodes of every document are organized in a tree structure
A tree structure, tree diagram, or tree model is a way of representing the hierarchical nature of a structure in a graphical form. It is named a "tree structure" because the classic representation resembles a tree, although the chart is gener ...
, called the ''DOM tree'', with the topmost node named as "Document object". When an HTML page is rendered in browsers, the browser downloads the HTML into local memory and automatically parses it to display the page on screen. However, the DOM does not necessarily need to be represented as a tree, and some browsers have used other internal models.
JavaScript
When a web page is loaded, the browser creates a Document Object Model of the page, which is an object oriented representation of an HTML document that acts as an interface between JavaScript and the document itself. This allows the creation of dynamic web pages, because within a page JavaScript can:
* add, change, and remove any of the HTML elements and attributes
* change any of the CSS styles
* react to all the existing events
* create new events
Implementations
Because the 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).
Layout engines
Web browsers rely on layout engines to parse HTML into a DOM. Some layout engines, such as Trident/MSHTML, are associated primarily or exclusively with a particular browser, such as Internet Explorer. Others, including Blink
Blinking is a bodily function; it is a semi-autonomic rapid closing of the eyelid. A single blink is determined by the forceful closing of the eyelid or inactivation of the levator palpebrae superioris and the activation of the palpebral portio ...
, WebKit
WebKit is a browser engine developed by Apple and primarily used in its Safari web browser, as well as on the iOS and iPadOS version of any web browser. WebKit is also used by the BlackBerry Browser, PlayStation consoles beginning from the PS ...
, and Gecko
Geckos are small, mostly carnivorous lizards that have a wide distribution, found on every continent except Antarctica. Belonging to the infraorder Gekkota, geckos are found in warm climates throughout the world. They range from .
Geckos ar ...
, are shared by a number of browsers, such as Google Chrome
Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS ...
, Opera
Opera is a form of theatre in which music is a fundamental component and dramatic roles are taken by singers. Such a "work" (the literal translation of the Italian word "opera") is typically a collaboration between a composer and a librett ...
, Safari
A safari (; ) is an overland journey to observe wild animals, especially in eastern or southern Africa. The so-called "Big Five" game animals of Africa – lion, leopard, rhinoceros, elephant, and Cape buffalo – particularly form an importa ...
, and Firefox. The different layout engines implement the DOM standards to varying degrees of compliance.
Libraries
DOM implementations:
* libxml2
libxml2 is a software library for parsing XML documents. It is also the basis for the libxslt library which processes XSLT-1.0 stylesheets.
Description
Written in the C programming language, libxml2 provides bindings to C++, Ch, XSH, C#, Py ...
* MSXML
Microsoft XML Core Services (MSXML) are set of services that allow applications written in JScript, VBScript, and Microsoft development tools to build Windows-native XML-based applications. It supports XML 1.0, DOM, SAX, an XSLT 1.0 processor, ...
* Xerces is a collection of DOM implementations written in C++, Java and Perl
xml.dom
for Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (pro ...
* XML for <SCRIPT> is a JavaScript-based DOM implementation
PHP.Gt DOM
is a server-side DOM implementation based on libxml2
libxml2 is a software library for parsing XML documents. It is also the basis for the libxslt library which processes XSLT-1.0 stylesheets.
Description
Written in the C programming language, libxml2 provides bindings to C++, Ch, XSH, C#, Py ...
and brings DOM level 4 compatibility to the PHP
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group ...
programming language
Domino
is a Server-side (Node.js) DOM implementation based on Mozilla's dom.js. Domino is used in the MediaWiki
MediaWiki is a free and open-source wiki software. It is used on Wikipedia and almost all other Wikimedia websites, including Wiktionary, Wikimedia Commons and Wikidata; these sites define a large part of the requirement set for MediaWiki ...
stack with Visual Editor.
SimpleHtmlDom
is a simple HTML document object model in C#, which can generate HTML string programmatically.
APIs that expose DOM implementations:
* JAXP (Java API for XML Processing) is an API for accessing DOM providers
* Lazarus ( Free Pascal IDE) contains two variants of the DOM - with UTF-8 and ANSI format
Inspection tools:
* DOM Inspector
DOM Inspector (DOMi) is a web developer tool created by Joe Hewitt and was originally included in Mozilla Application Suite as well as versions of Mozilla Firefox prior to Firefox 3
Mozilla Firefox 3.0 is a version of the Firefox web browser ...
is a web developer tool
See also
* Shadow DOM
Web Components are a set of features that provide a standard component model for the Web allowing for encapsulation and interoperability of individual HTML elements.
Primary technologies used to create them include:
* Custom Elements: APIs to ...
* Virtual DOM
A virtual DOM is a lightweight JavaScript representation of the Document Object Model (DOM) used in declarative web frameworks such as React, Vue.js, and Elm. Updating the virtual DOM is comparatively faster than updating the actual DOM (via Java ...
References
General references
*
*
*
*
External links
DOM Living Standard
by the WHATWG
Original W3C DOM hub
by the W3C DOM Working Group (outdated)
Web Platform Working Group
(current steward of W3C DOM)
{{DEFAULTSORT:Document Object Model
Application programming interfaces
HTML
Object models
World Wide Web Consortium standards
XML-based standards