DEV Community

Cover image for Mythbusting DOM: Was DOM Invented Alongside HTML?

Mythbusting DOM: Was DOM Invented Alongside HTML?

Serhii Babich on July 03, 2024

There is a common belief that the DOM emerged simultaneously with HTML and has always been an integral part of web development, with developers hav...
Collapse
 
efpage profile image
Eckehard

Even though Tim Bernder Lee is named as the "inventor" of HTML, he did not start with nothing. The Idea of a Standard Generalized Markup Language (SGML) had been around for quite some years. There are other languages like XML that have their own parsers too. XML and HTML are very similar, despite XML has no fixed keywords.

You can think of an XML-parser like a fast database. After reading an XML-file, many parsers keep the content in memory giving your access to the content. Does this sound familiar? At itΒ΄s core, each XML-parser is like the DOM.

So, the DOM is - at best - one under many.

But HTML has itΒ΄s quirks that possibly can drive parser developers nuts. Usually, a well formed XML-document is built like a tree. Each node has to be closed before you open a new one. This does not seem to be so strict in HTML. You can easily do something like this:

<p>this is <i><b>paragraph 1</p>
<p>this is paragraph 2</p>
<p>this is </i>para</b>graph 3</p>
Enter fullscreen mode Exit fullscreen mode

This is not well formed, tags are overlapping, but it is displayed as expected.

Collapse
 
babichweb profile image
Serhii Babich

Speaking of SGML β€” I mentioned this in my previous article;

"There are other languages like XML" β€” and there is an upcoming article about that.

Collapse
 
taliastorymaker profile image
Talia Hatfield

The reason why HTML is effectively the DNA of the web is that however you make your webpage, it will still end up with HTML in the browser. That's the danger, to me, of moving away from HTML too much. It puts more layers between your code and what the user sees and uses.

Yes, most HTML elements don't have much functionality, but many do have semantic meanings that can be meaningful for assistive technologies such as screen readers as well as search engines. So you have to be careful about that too.

Thread Thread
 
efpage profile image
Eckehard

This is not correct. Frameworks like React build the DOM directly with JS.

Thread Thread
 
taliastorymaker profile image
Talia Hatfield

I guess I don't understand what you mean. What's in the browser is still HTML.

Thread Thread
 
efpage profile image
Eckehard

No, HTML is just a text format. It tells the browser how to build the DOM. But you can also use API-calls to build the DOM from Javascript. This is what React does.

Collapse
 
nataliaiv90 profile image
Natalia Ivantsova

Waiting for the next chapter of this exciting story πŸ˜€

Collapse
 
ambroseus profile image
Eugene Samonenko

DOM is not DOOM πŸ™‚

Collapse
 
babichweb profile image
Serhii Babich

Rrright!

Collapse
 
zpwebbear profile image
Dmitriy Braginets

I fell smarter after reading it πŸ˜…

Collapse
 
babichweb profile image
Serhii Babich

That was a plan!

Collapse
 
oksana1 profile image
Oksana

DOM is not HTML)

Collapse
 
babichweb profile image
Serhii Babich • Edited

Or is it? Let's try to figure out in my next article ;)

Collapse
 
maryna_d64842c8c7142a11e3 profile image
Maryna

This is very interesting article. Thanks!

Collapse
 
babichweb profile image
Serhii Babich

Thank you!

Collapse
 
aleksander_makarov_0c27db profile image
Aleksander Makarov

DOM is not HTML! Nothing is HTML at all. Only HTML is HTML😁

Collapse
 
pashokmi profile image
Pavlo Melnyk

Super, I didn't know that DOM is not HTML

Collapse
 
babichweb profile image
Serhii Babich

Aaaand I can't find where this article stated DOM is or is not an HTML