HTML DOM
Reading and changing the document from script.
HTML DOM is taught here in 13 lessons, running from Selecting elements through to Debugging and testing DOM code. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.
| Track | Front-end Development |
| Lessons | 13 |
| Level | Beginner to intermediate |
| Reading time | about 3 hours |
| Prerequisites | Helpful, but not required: TypeScript |
Lessons
- Selecting elementsFind nodes with CSS selectors, understand when you get a static list versus a live collection, and scope a search to one subtree.
- Reading and updating content safelytextContent versus innerHTML versus form properties, attribute and class handling, and the script-injection bug that comes with the powerful option.
- Creating, removing and traversingBuild nodes and fragments efficiently, detach and replace them correctly, and walk the tree with the element-only navigation properties.
- Attributes, classes and inline styles from scriptAttribute versus property, boolean attributes, the dataset naming rules, classList operations, and the difference between inline style and computed style.
- Events and delegation in depthThe options object, capture and bubble, delegation with closest, removing listeners reliably, and custom events between components.
- Forms, validation and user inputRead and set values, use the constraint validation API with your own messages, collect data with FormData, and manage focus and selection.
- Geometry, scrolling and visibilityMeasure elements correctly, understand which size property you want, scroll deliberately, and observe visibility with the observer APIs.
- Templates, cloning and efficient renderingUse the template element for inert markup, clone it into a fragment, and render lists without rebuilding the whole DOM on every change.
- Observing changes with MutationObserverWatch for added nodes, attribute changes and text edits, understand the record batching, and avoid the observer loop.
- Web Components: custom elements and shadow DOMDefine a custom element, use its lifecycle callbacks correctly, encapsulate styles in a shadow root, and compose with slots and events.
- Performance and memory in DOM codeStop layout thrashing by separating reads from writes, batch with animation frames, and find the listener and node leaks that make a page degrade over time.
- Accessibility for DOM scriptingManage focus deliberately, keep ARIA state in sync with the DOM, announce changes with live regions, and support the keyboard a custom widget implies.
- Debugging and testing DOM codeUse DevTools breakpoints and console utilities to inspect live nodes, then test the same code in JSDOM and in a real browser.
More in Front-end Development
HTML CSS JavaScript TypeScript AJAX JSON Tailwind CSS Bootstrap 5 Foundation Vue.js React Next.js Angular jQuery ECharts Chart.js SVG Font Awesome
FAQ
How long does the HTML DOM course take?
It has 13 lessons, about 3 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for HTML DOM?
Not strictly. It helps to have read TypeScript first, because some lessons build on it, but every lesson explains its own assumptions.
What should I read after HTML DOM?
Continue with AJAX (12 lessons), the next course in Front-end Development.