Skip to content

DOM vs HTML

The DOM is a live representation of the HTML. When JavaScript modifies the DOM, the browser re-renders accordingly — but the HTML file itself never changes.

// When you modify the DOM, the page updates
document.body.innerHTML = '<h1>New Content</h1>';
// The HTML file is NOT changed, but the page renders differently
AspectHTMLDOM
LocationOn disk (file)In memory (browser)
UpdatesRequires page reloadLive, updates instantly
Dynamic contentStaticCan be changed dynamically
ErrorsBrowser parses forgivinglyDOM is already parsed
  1. Browser loads HTML file
  2. Parses HTML → creates DOM tree
  3. JavaScript modifies DOM nodes
  4. Browser re-renders based on DOM changes
  5. Original HTML file remains unchanged
  • DOM is the live, in-memory representation of the page
  • Modifying the DOM updates what the user sees
  • The original HTML file is never modified
  • DOM manipulation is how JavaScript creates interactivity