The following questions are confusing me. I know they are related, but...
HTML5 defines HTML, XHTML and the DOM.
The DOM is namespace aware. When you use DOM methods you must take into account which namespace each element is in, but the default is the HTML (http://www.w3.org/1999/xhtml
) namespace.
HTML and XHTML are serializations that are converted into DOMs by parsing.
XHTML is namespace aware and XHTML documents apply namespaces according to the rules of XML, so all namespaces must be assigned to each element explicitly. XHTML is converted to a DOM using an XML parser.
HTML is also namespace aware, but namespaces are assigned implicitly. HTML is converted to a DOM using an HTML parser, which knows which elements go in which namespace. That is, it knows that <div>
goes in the http://www.w3.org/1999/xhtml
namespace and that <svg>
goes in the http://www.w3.org/2000/svg
namespace. Elements like <script>
can go in either the http://www.w3.org/1999/xhtml
or the http://www.w3.org/2000/svg
namespace depending on the context in which they appear in the HTML code.
The HTML parser knows about HTML elements
, SVG elements
, and MathML elements
and no others. There is no option to use elements from other namespaces, neither implicitly nor explicitly. That is, xmlns
attributes have no effect.