4

The Mozilla MDN documentation for XMLDocument includes the following note — emphasis mine:

The XMLDocument interface represents an XML document. It inherits from the generic Document and does not add any specific methods or properties to it: nevertheless, several algorithms behave differently with the two types of documents.

The linked spec says something similar:

A document is said to be an XML document if its type is "xml"; otherwise an HTML document. Whether a document is an HTML document or an XML document affects the behavior of certain APIs.

I can find no information on what behaves differently, though. Is this enumerated anywhere?

ELLIOTTCABLE
  • 17,185
  • 12
  • 62
  • 78
  • It's probably related to the fact that xml element must always have closing tags – Konrad Jan 05 '23 at 21:36
  • 1
    HTML also has some rules about the relationships between certain tags. For instance, `` has to be a child of ``, and `` has to be inside ``.
    – Barmar Jan 05 '23 at 21:39
  • 1
    I doubt there is a list, and if one were to make one for this question they'd have to subscribe to most Web standards PRs to keep it up to date. You can get a first view by running a search for `HTML document` in https://dom.spec.whatwg.org/ but I guess other specs will have their own special handling. – Kaiido Jan 05 '23 at 23:50

1 Answers1

2

If you click on the definition of HTML document you'll find where it's referenced. From that you can find out that createElement() branches on it, for instance.

Through https://dontcallmedom.github.io/webdex/h.html#HTML%20document%40%40dom%25%25dfn you can find other specifications that reference that definition.

Though you would also have to check https://dontcallmedom.github.io/webdex/x.html#XML%20document%40%40dom%25%25dfn and https://dontcallmedom.github.io/webdex/t.html#type%40%40Document%40dfn to be comprehensive.

(There are also syntax and conformance differences between HTML and XML as some of the initial comments above suggest, but those don't really follow from this concept, which only comes into play once you have a node tree.)

Anne
  • 7,070
  • 1
  • 26
  • 27