DOM (Document Object Model)
The DOM is the browser's live, tree-shaped representation of an HTML page. Each element, attribute, and piece of text becomes a node that JavaScript can read and change.
Web
When a browser loads HTML, it parses it into the DOM — a structured object you can navigate and manipulate. Changing the DOM updates what the user sees without reloading the page.
The DOM is what makes pages interactive: JavaScript uses methods like document.querySelector() to find elements and update their content, styles, or attributes.
Examples
JavaScript
const heading = document.querySelector("h1");
heading.textContent = "Updated!";Output:
Changes the first <h1> on the page to read 'Updated!'.