01 The DOM is not your HTML
Your .html file is text. The browser reads it once and builds a live tree of objects in memory. That tree is the Document Object Model, and it is what JavaScript talks to.
Two consequences that explain a lot of confusion:
- Changing the DOM never changes your file. Reload and your edits are gone.
- The browser repairs broken markup while building the tree, so what you inspect can differ from what you typed.
"View source" shows the file the server sent. The Elements tab in devtools shows the live DOM. When they disagree, something changed the tree after loading — usually your own script.
Your file The tree the browser builds
<ul id="list"> ul#list
<li class="plant"> └── li.plant
<h3>Fern</h3> └── h3
</li> └── "Fern" (a text node)
</ul>