开发者

Difference between HTML and DOM

开发者 https://www.devze.com 2023-01-23 23:08 出处:网络
What is the difference betwee开发者_如何学运维n DOM and HTML?DOM is a model of a document with an associated API for manipulating it.

What is the difference betwee开发者_如何学运维n DOM and HTML?


DOM is a model of a document with an associated API for manipulating it.

HTML is a markup language that lets you represent a certain kind of DOM in text.

Other kinds of DOMs can be expressed in other markup languages, for example RSS and Atom can be converted to a DOM and manipulated with the same API as an HTML or XHTML document (more or less anyway; there are some HTML specific DOM extensions).


The Document Object Model (DOM) is a language-independent model made up of objects representing the structure of a document. HTML is one language for writing such documents.


Well, if you look in things like firebug, you can also check out the "DOM". Then they usually mean the current state the HTML page is in. So if you, for example, have a html page and add a tag with javascript.

The actual HTML of the page is still the same, but the "DOM" however has changed.

Notice that this isn't the right definition of DOM, but I thought this might be what you meant.


DOM is the tree model to represent HTML.


The HTML of a page is a string, and the DOM of the page is what happens when you take that string and construct an object in the object-oriented programming sense of the term "object". Creating that object is how JavaScript is able to interact with the page:

https://en.wikipedia.org/wiki/Document_Object_Model#JavaScript

When a web page is loaded, the browser creates a Document Object Model of the page, which is an object oriented representation of an HTML document, that acts as an interface between JavaScript and the document itself and allows the creation of dynamic web pages.

0

精彩评论

暂无评论...
验证码 换一张
取 消