From the course: HTML for Programmers

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

The DOM

The DOM

- [Instructor] The DOM or document object model is a programming interface for webpages. It represents the page content so programs can alter the structure, style, and content. Each HTML element is represented as a DOM node. We can think of the page structure as a tree where the HTML node is the root of the tree and all other nodes flow as a series of branches with different levels depending on how the nodes are nested. The DOM is programming language agnostic, meaning it interfaces with any programming language. With the DOM, we can create and build web documents and traverse the different HTML elements as nodes in the DOM. For example, let's suppose we have the following HTML code. We have a header with a nav followed by an unordered list with three list items, each containing a link. How would we start at the header node and traverse our way down the DOM tree to the first anchor link? using JavaScript's query selector…

Contents