The Document Object Model (DOM) is the programming interface for an HTML document. It represents the page as a tree of objects that JavaScript can read and change.
The browser parses the HTML and builds a node for each element, attribute and piece of text. The document object is the root of that tree. Scripts start from it to find and change nodes, or to add and remove them, and the screen updates to match.
The DOM is not the HTML source. It reflects the page as it is now, including every change made by scripts.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Saved in this browser - sign in to keep your review list.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Keep going - a few more words and AI can grade it.
Interview lens
How interviewers actually use this question
Likely follow-ups
How is a DOM property different from the HTML attribute with the same name?The attribute is the value written in the markup. The property is the node's current state, like an input's value after the user types.
Why can frequent DOM changes make a page slow, and how do you keep the cost down?Changes can force style, layout and paint work. Batch writes, avoid reading layout between writes, and build off-screen in a DocumentFragment.
A script adds an element after load. Will you see it in view-source? Where would you look instead?View-source shows the HTML the server sent. The DevTools Elements panel shows the live DOM, including changes made by scripts.
What is the difference between DOMContentLoaded and load, and which one do you wait for to touch the DOM?DOMContentLoaded fires once the HTML is parsed and the tree is built. load also waits for images and stylesheets. DOM work needs only the first.
The DOM, or Document Object Model, is the browser's representation of a page as a tree of objects, and it's the interface JavaScript uses to read and change that page.
When the browser parses the HTML, it builds a node for every element, attribute and piece of text, and links them into that tree.
The document object sits at the root, so a script starts from it to find nodes, change them, or add and remove them.
When a script changes the tree, the browser updates the screen to match.
The DOM is not the HTML source but the page as it is right now, so it includes every change scripts have made and can differ from what view-source shows.
Weak answers to avoid
Says the DOM is just the HTMLHTML is the text the server sent. The DOM is the live tree the browser built from it, and scripts keep changing it, so the two can differ after load.
Treats the DOM as part of JavaScriptThe DOM is a browser API with its own standard, and JavaScript is the language that calls it. Node.js has no document object by default.
Mixes it up with React's virtual DOMThe virtual DOM is a library's in-memory copy used to work out what changed. The real DOM is the browser's tree. Answer about the real one unless asked.
Gives a one-line definition and stops'A tree of objects' alone skips how it gets built. Walk through parsing, one node per element, attribute and text, the document root, and scripts changing it.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.