LSN #11 What Is the DOM?

The DOM (Document Object Model) is a tree-like structure that your browser builds when it reads an HTML page. It represents everything on the page in a way that JavaScript can understand and interact with.

So when your browser loads this HTML:

<html>
  <body>
    <h1>Hello!</h1>
    <p>This is a web page.</p>
  </body>
</html>

It creates a DOM that looks like this:

html
└── body
    ā”œā”€ā”€ h1 ("Hello!")
    └── p ("This is a web page.")

HTML is like the ingredients list for a cake.

DOM is the actual cake on the table that JavaScript can touch, slice, decorate, or rearrange.

The DOM is like a live diagram of the web page.