JavaScript: DOM

What is DOM?

DOM which is short for Document Object Model , is the specification for how objects in a web page should appear. It is an interface that allows a programming language to manipulate the content, structure, and style of a website. When a web page is loaded, the browser creates a Document Object Model of that page. In the DOM, documents have a logical structure which is very much like a tree. For example, the opening tag is the root, and all tags within it are its nodes and so on. The DOM is browser independent as well as platform independent and it achieves this independence by representing the contents of the web document as a generic tree structure . It is governed by its own standard, maintained by the W3C (World Wide Web Consortium).


HTML you write is parsed by the browser and turned into the DOM. Dynamic web pages relies on the DOM to dynamically change the appearance of Web pages after they have been downloaded to a user's browser. DOM does not define what information in a document exists and how the document is structured or implemented. It represents a web document or a web page, that allows developers a way of representing everything on a web document so that it is accessible via a common set of properties and methods . Anything found in an HTML document can be accessed, changed, deleted, or added using the Document Object Model.

Browsers and DOM

Different browsers have different implementations of the DOM, and these implementations exhibit varying degrees of conformance to the actual DOM standard, but every web browser uses some document object model to make web pages accessible via JavaScript. The HTML DOM is one of the most important aspects of JavaScript that you'll encounter. The DOM is not a programming language, but without it, the JavaScript language wouldn't have any model or notion of web pages, HTML documents, XML documents , and their component parts.