HTML DOM - Overview



The Document Object Model (DOM) is a W3C standard. It defines a standard for accessing documents like HTML and XML.

Definition of DOM as put by the W3C is −

The Document Object Model (DOM) is an application programming interface (API) for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

DOM defines the objects and properties and methods (interface) to access all XML elements. It is separated into 3 different parts / levels −

  • Core DOM − standard model for any structured document

  • XML DOM − standard model for XML documents

  • HTML DOM − standard model for HTML documents

HTML DOM is a standard object model for HTML. HTML documents have a hierarchy of informational units called nodes; DOM is a standard programming interface of describing those nodes and the relationships between them.

As HTML DOM also provides an API that allows a developer to add, edit, move or remove nodes at any point on the tree in order to create an application. This example changes the value of an HTML element with id="demo":

<h1 id="demo">This is a Heading</h1>

<script>
document.getElementById("demo").innerHTML = "HTML DOM Demo";
</script>

The above HTML code will produce following result:

HTML DOM Demo

Advertisements