Navigating in the Document Tree

It is time to dive deeper into the details about the functionality covered by the Document Object Model. Let's begin!

We'll cover the following

As is obvious, the entire document that represents a web page can be depicted as a tree. This tree is built up from nodes, where each node has exactly one parent, except the root node that has no parent, and each node may have zero, one, or more child nodes. HTML elements, texts, and attributes of elements are all nodes in this tree.

The image in the DOM Basics lesson already showed you a simple HTML markup as a hierarchy.

The image given below shows a bit more compound markup; its source is detailed in Listing 6-2.

Listing 6-2: The DOM tree

Get hands-on with 1200+ tech skills courses.