The document object model is the browser's internal representation of HTML. It's based on the idea of 'children'. So a <p>
tag might contain several text nodes and several <span>
tags, like this:
<p><span>Hello,</span> this is some text. <span>It</span> is just a short paragraph</p>
This <p>
tag has 4 children: two <span>
s, and two text nodes (this is some text
and is just a short paragraph
). The other bits of text are children of their respective <span>
tags.
The browser stores this information (instead of just storing a huge stream of HTML, which is very difficult to process) in its internal memory. This makes it much easier to format it using Cascading Style Sheets (CSS) and to make changes to it using JavaScript (create and delete parts, move parts from one parent to another, etc).
All versions of HTML (except perhaps very early ones) use the DOM. Each version has rules, such as which tags are valid, and which can be children to each element. These rules are implemented when processing the HTML and creating a DOM representation of it.