JavaScript DOM Guide
The DOM (Document Object Model) API allows JavaScript to interact with HTML and XML documents. It provides methods to select, create, modify, and remove elements. The guide walks through Selecting Elements, Creating & Modifying Elements, Traversing the DOM, Events, Styles & Classes. `querySelector()` returns the first matching element, `querySelectorAll()` returns all matches as a static NodeList. `getElementById()`, `getElementsByClassName()`, `getElementsByTagName()` are legacy alternatives. `createElement()` creates new elements, `appendChild()` and `insertBefore()` add them to the DOM. `innerHTML`, `textContent`, `setAttribute()` modify element content and attributes. The guide is organized into 5 sections that build on each other, each pairing a prose explanation with runnable code. Browse the individual methods covered by this guide in the DOM category. Key APIs covered include document.getElementById(), document.querySelector(), document.querySelectorAll(), element.addEventListener(), element.removeEventListener(), document.createElement(). Related guides: Arrays, Strings, Numbers, Math, Date. This is one of 145 JavaScript guides on JS Reference — see the full list on the guides page.