Home web designing DOM DOM- Definition of Document Object Model or DOM

DOM- Definition of Document Object Model or DOM

0
SHARE

What is DOM

The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. DOM or document object model in not a programming language . It is style to defines the logical structure of documents . With this logical stucture user can easily access and manipulate content of the webpage .

In the DOM , document is create like a tree structure with root and branches . In the DOM tree structure root is on top side . Just like following image.

DOM Stucture
DOM Structure

DOM Structure

In the DOM specification, the term “document” is used for complete page. For example a html web page start from code <html> and end at tag </html> . All of content and tag are place in a webpage is called document .

dom1
dom1

Top of tag is called root of document in DOM . As you know , html webpage start with tag <html> . So this tag is called root of Document Object Model . This is also known as Node or parent Node .

READ ALSO : -  Easy Way To Compress Html Delivery On Website

In the upper image html tag structure is as follows.

<html>
<head>
<title>This is the title</title>
</head>
<body>
<h1> This is the h1 title </h1>
<p> This is paragraph text </p>
</body>
</html>

In DOM , this html code is divided in well structured format .

First tag is html is parent node or Root of the document . After that head tag and body tag is a directly connected to Html tag so these are known as child of html tag .

Under the head tag title tag is also known as child element and of head . Text that is written in the title, “This is the title ” is also a Node or a child of title tag . This is also Known as Text Node .

Using DOM or Document Object Model , User can easily access and manipulate a specific area of document .