DOM

The Document Object Model (DOM) is an Application Programming Interface (API) used in web browsers or other devices that give programmers and developers a way of accessing the elements within HTML and XML documents. The structure of the DOM for any document will resemble the actual structure of the markup of the document. For example, consider the below simple HTML document.

<html>
<head>
<title>Example</title>
</head>
<body>
<h1>Example Page</h1>
<p>This is an example page.</p>
</body>
</html>

The DOM for this document will include all of the elements and any text nodes within those elements. This code will create an object hierarchy as shown below.

DOM example

For each element under the document root (<html>), there is an element node, and these element nodes have text nodes containing the text that is within the element. If there were an element with attributes, an attribute node would be created for that element, and any text for the attribute would create a text node under that attribute node.

The most common programming language used in accessing the DOM is JavaScript, which is used very often in web sites. This allows for dynamic changes to be made to the DOM, which can include showing/hiding elements (such as text, tables, images, and entire divisions), moving elements, animating elements, and more.

In the past, the DOM had fundamental differences between browsers, but today has become much more standardized in modern browsers. This allows for easier cross-browser scripting to be performed by developers.

Additional Information

Also see: Internet definitions, Programming definitions