HTML 5 Adding XML Namespaces

情到浓时终转凉″ 提交于 2019-12-01 18:27:33

问题


Can anyone tell me how you add additional XML namespaces to an HTML 5 document?

I'm trying to create an HTML 5 version of the following

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="https://www.facebook.com/2008/fbml">

Is it simply a case of dropping the xhtml namespace:

<html xmlns:og="http://ogp.me/ns#"
      xmlns:fb="https://www.facebook.com/2008/fbml">

Thanks.


回答1:


According to the WHATWG, in html 5 you are permitted to use the xmlns attribute on each html element as long as the namespace is http://www.w3.org/1999/xhtml (the namespace of the document)

Will there be support for namespaces in HTML?

HTML is being defined in terms of the DOM and during parsing of a text/html all HTML elements will be automatically put in the HTML namespace, http://www.w3.org/1999/xhtml. However, unlike the XHTML serialization, there is no real namespace syntax available in the HTML serialization (see previous question). In other words, you do not need to declare the namespace in your HTML markup, as you do in XHTML. However, you are permitted to put an xmlns attribute on each HTML element as long as the namespace is http://www.w3.org/1999/xhtml



来源:https://stackoverflow.com/questions/6372362/html-5-adding-xml-namespaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!