Amir Gonnen
Amir Gonnen

Reputation: 3727

HTML default namespace vs. explicit namespace

Why is this not rendering correctly on Chrome:

<h:html xmlns:h="http://www.w3.org/1999/xhtml">
  <h:head/>
  <h:body>
    <h:ul>
      <h:li>
        A
      </h:li>
      <h:li>
        B
      </h:li> 
    </h:ul>
  </h:body>
</h:html>

While this does render correctly? :

<html xmlns="http://www.w3.org/1999/xhtml">
  <head/>
  <body>
    <ul>
      <li>
        A
      </li>
      <li>
        B
      </li> 
    </ul>
  </body>
</html>

What am I missing here? Doens't default namespace supposed to behave the same as specifying namespace explicitly?

Upvotes: 1

Views: 157

Answers (1)

Quentin
Quentin

Reputation: 943108

HTML is not XML.

Your code works fine, when I test it in Chrome, with an application/xml Content-Type.

It doesn't work as text/html.

HTML allows an xmlns attribute for compatibility with XML, and it allows some XML (such as SVG) to be embedded in it, but an HTML parser won't support namespace aliases for HTML elements.

Upvotes: 2

Related Questions