Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confused by relation between DOM and HTML (APIs)

How are DOM and HTML related? Is one subset of another, is one a more abstract concept than the another? Is HTML an extension of DOM? Or do they describe rather unrelated concepts (related only in that you can transform from HTML into DOM)? How would you draw these 2 in one picture if you had to?

For example, what is the purpose of these difference specs. Both first and last links contain information about HTMLElement..

  1. http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/
  2. http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/
  3. http://www.w3.org/TR/html5/

I found a possible answer to this question here: http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-1176245063-h2, which is

The goals of the HTML-specific DOM API are:

  • to specialize and add functionality that relates specifically to HTML documents and elements
  • ...
  • to provide convenience mechanisms, where appropriate, for common and frequent operations on HTML documents.

Does this mean that the 3rd link in the list above extends the DOM Core, which is described in the 1st link?

Or if you implement DOM Core, that allows you to manipulate simple documents, but if you implement HTML, that gives you like a super-DOM that allows you to manipulate more complicated objects?

Finally, say you want to implement your own browser that is able to open only HTML5 websites (render, as well as support JavaScript). Is it enough to read the specification found in the 3rd link, or do you first need to implement everything provided in DOM and then implement HTML5 specific things?

UPDATE
I guess I'm wondering about DOM API vs HTML API vs DOM HTML API vs HTML DOM API.

like image 266
Karolis Avatar asked Nov 29 '10 18:11

Karolis


People also ask

What is difference between DOM and API?

The Document Object Model (DOM) is an application programming interface (API) for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

What is the difference between HTML and DOM?

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.

What is DOM relative to HTML?

The HTML DOM is a standard object model and programming interface for HTML. It defines: The HTML elements as objects. The properties of all HTML elements. The methods to access all HTML elements.

Is DOM part of web API?

The DOM is not part of the JavaScript language, but is instead a Web API used to build websites. JavaScript can also be used in other contexts.


2 Answers

HTML is text and the DOM is the in-memory object model to represent the tree that the HTML described.

like image 164
Lou Franco Avatar answered Sep 29 '22 11:09

Lou Franco


The HTML spec describes HTML in terms of a text document with a specific syntax. The DOM on the other hand describes the object-model that the browser generates, when it parses the HTML document. But both specs kind of describe the same abstract model which is the elements and attributes of HTML.

The DOM-core is the object model that is common for all XML documents (including HTML) with elements and attributes. The HTML-DOM is an extension of the core DOM with more specific interfaces for the various HTML elements.

like image 45
JacquesB Avatar answered Sep 29 '22 09:09

JacquesB