What is the Document Object Model?

You have read about the DOM. What is the Document Object Model and what do the three words mean in this phrase?

"The Document Object Model (DOM) is an abstract representation of an HTML document that can be queried and manipulated through its API." This quote was taken from page 62 of The Web Application Hacker's Handbook 2nd Edition.

An HTML document is "a file containing hypertext markup language" (taken from 0:07 of the video here).

The word object is an instance of a class (1). The word model refers to the combination of the structure and the behavior of the object (1). The structure and behavior of the object are not persisted via the DOM (2).

(1) 'The name "Document Object Model" was chosen because it is an "object model" in the traditional object oriented design sense: documents are modeled using objects, and the model encompasses not only the structure of a document, but also the behavior of a document and the objects of which it is composed. In other words, the nodes in the above diagram do not represent a data structure, they represent objects, which have functions and identity.' This quote was taken from this W3.org web page.

(2) 'The Document Object Model is not a way of persisting objects to XML or HTML. Instead of specifying how objects may be represented in XML, the DOM specifies how XML and HTML documents are represented as objects, so that they may be used in object oriented programs.' This quote was taken from W3.org web page.

Leave a comment

Your email address will not be published. Required fields are marked *