Document Object Model
| Document Object Model (DOM) | |
|---|---|
Example of DOM hierarchy in an HTML document | |
| Abbreviation | DOM |
| Latest version | DOM4[1] November 19, 2015 |
| Organization | World Wide Web Consortium, WHATWG |
| Base standards | WHATWG DOM Living Standard W3C DOM4 |
| HTML |
|---|
| HTML and variants |
| HTML elements and attributes |
|
| Editing |
|
| Character encodings and language |
|
| Document and browser models |
|
| Client-side scripting and APIs |
|
| Graphics and Web3D technology |
| Comparisons |
|
The Document Object Model (DOM) is a cross-platform[2] and language-independent API that treats an HTML or XML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with a logical tree. Each branch of the tree ends in a node, and each node contains objects. DOM methods allow programmatic access to the tree; with them one can change the structure, style or content of a document.[2] Nodes can have event handlers (also known as event listeners) attached to them. Once an event is triggered, the event handlers get executed.[3]
The principal standardization of the DOM was handled by the World Wide Web Consortium (W3C), which last developed a recommendation in 2004. WHATWG took over the development of the standard, publishing it as a living document. The W3C now publishes stable snapshots of the WHATWG standard.
In HTML DOM (Document Object Model), every element is a node:[4]
- A document is a document node.
- All HTML elements are element nodes.
- All HTML attributes are attribute nodes.
- Text inserted into HTML elements are text nodes.
- Comments are comment nodes.
- ^ All versioning refers to W3C DOM only.
- ^ a b "Document Object Model (DOM): definition, structure and example". IONOS Digitalguide. Retrieved 2022-04-21.
- ^ "Document Object Model (DOM)". W3C. Retrieved 2012-01-12.
The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents.
- ^ "JavaScript HTML DOM".