Home > Net >  Regarding HTML, What does it mean that "elements are part of the DOM"?
Regarding HTML, What does it mean that "elements are part of the DOM"?

Time:01-14

From the following paragraphs:

"Elements and tags are not the same things. Tags begin or end an element in source code, whereas elements are part of the DOM, the document model for displaying the page in the browser."

"The DOM (Document Object Model) is an API that represents and interacts with any HTML or XML document. The DOM is a document model loaded in the browser and representing the document as a node tree, where each node represents part of the document (e.g. an element, text string, or comment)."

Sources: https://developer.mozilla.org/en-US/docs/Glossary/Element

https://developer.mozilla.org/en-US/docs/Glossary/DOM

Does it mean that an element and a node are the same thing? And do elements only exist when browsers interpret an html document? Meaning we couldn't call html element to the plain text we write on a text editor/IDEs

I'm trying to elaborate a clear explanation about what html elements are (apart from "start tag, content, /end tag") but I don't really get it yet. The courses I made only got me this far, but I want to understand in depth.

Am I going the right direction?

I searched definitions of "html elements" online, but most of the times I found vague explanations and nothing that went in depth on what it's got to do with the DOM (which I'm just begining to study, so I don't know much about yet)

Thankful for any help

CodePudding user response:

Does it mean that an element and a node are the same thing?

No. Elements are nodes but the reverse is not necessarily true (e.g. there are text nodes and comment nodes).

And do elements only exist when browsers interpret an html document? Meaning we couldn't call html element to the plain text we write on a text editor/IDEs

People will argue for both. It's not really useful to do so. Just make sure you are being clear about the context.

  • Related