The Document Object Model (DOM) is a W3C standardized programming interface that allows scripts to examine and modify the contents of the web browser. By the DOM, the composition of an HTML or XML document is represented as a set of objects – which can represent a window, a sentence or a style, for example – linked in a tree structure. Using the DOM, a script can modify the document present in the browser by adding or removing nodes from the tree.
- Model: A model is used to represent something. The DOM represents the document that is in the browser.
- Object: In programming, an object is a container that has properties and methods – which are variables and actions about what it represents. DOM objects can represent a window, a document, a sentence or a style.
- Document: The DOM is a document, such as a web page displayed in a browser. A web page starts with a tag followed by the tag in which the rest of the document is located. The DOM represents the document displayed by a tree structure, with nodes.
Implementation and Technical Aspects of DOM
Before standardization by the W3C, each web browser had its own Document Object Model. If the basic language for manipulating web documents was quickly standardized around JavaScript, it was not the same for the precise series of functions to be used and the way to navigate the document.
The W3C specification stipulates the objects, methods and properties that a web browser must make available. The main object categories of a DOM tree are document, elements, and attributes.
---
Illustration: Naveen Ankireddy
URL: https://medium.com/@naveenkumarreddyankireddy/basic-explanation-on-dom-73ed11ea974d
Each browser implements the DOM in its programming language. The DOM specification is aligned with JavaScript, which is recognized by all web browsers. Any part of a web page can be modified programmatically, and the program will work on any web browser that complies with the DOM standard. Technically the DOM allows you to read and edit any document using tags, with any programming language that offers a DOM programming interface.
DOM is used to represent the structure of a document and its elements in the form of a tree. It is therefore preferable to go through and memorize the entire document before you can perform the desired treatments. For this reason, programs using DOM often have a large memory footprint being processed. Conversely, from a given DOM tree, it is possible to generate documents in the desired markup language, which can in turn be manipulated by the DOM interface.
DOM is used to easily edit XML documents or access the content of web pages. In cases that do not require manipulating XML documents, but just reading them, the SAX method can also be chosen because it processes the elements sequentially without loading the document into memory. It is required when the size of the document exceeds the memory capacity.