The HTML DOM

The HTML DOM is a tree version of how the document looks. Here is a very simple example of an HTML document:

<!doctype HTML><html>    <head>        <title>Cool Stuff!</title>    </head>    <body>        <p>Awesome!</p>    </body></html>

Here's how its tree version will look:

The previous diagram is just a rough representation of the DOM tree. HTML tags consist of head and body; furthermore, the <body> tag consists of a <p> tag, whereas the <head> tag consists of the <title> tag. Simple!

JavaScript has access to the DOM directly, and can modify the connections between these nodes, add nodes, remove nodes, change contents, attach event listeners, and so ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.