浏览器是否支持带有使用名称空间的标记的HTML文档(请参阅代码)? [英] Do browsers support an HTML document with markup that uses namespaces (see code)?
问题描述
这里是您的HTML:
< html>
< head>
< / head>
< body>
< input type =button/>
< / body>
< / html>
以下是关于命名空间的HTML:
< h:html xmlns:h =http://www.w3.org/1999/xhtml>
< h:头>
< / h:头>
< h:body>
< h:input type =button/>
< svg:svg xmlns =http://www.w3.org/2000/svg/>
< / h:body>
< / h:html>
有问题吗?
仅供参考SVG使用名称空间并通过浏览器正确显示。请参阅此。
It seems like it's possible to use namespaces in an HTML document. Although, I've never seen it done. If I used namespaces in my document would browsers render it correctly?
Here is your HTML:
<html>
<head>
</head>
<body>
<input type="button"/>
</body>
</html>
Here is your HTML on namespaces:
<h:html xmlns:h="http://www.w3.org/1999/xhtml">
<h:head>
</h:head>
<h:body>
<h:input type="button"/>
<svg:svg xmlns="http://www.w3.org/2000/svg"/>
</h:body>
</h:html>
Any questions?
FYI SVG uses namespaces and is rendered correctly by browsers. See this.
Using XML mechanisms (like XML namespaces and prefixes and assuming that clients correctly process markup according to the XML processing model) is not a robust way to publish HTML. When publishing HTML, make sure you're doing it with what XML would call the "default namespace". You might get lucky that some browsers implement namespaces, or simply ignore prefixes, but I would recommend to not count on that. That's all different when you're just working in your own XML-based environment, where the two XML you're showing indeed are pretty much equivalent. But even then you should make sure that whatever leaves that environment matches the outside world's assumptions, such as HTML not using namespace prefixes at all.
这篇关于浏览器是否支持带有使用名称空间的标记的HTML文档(请参阅代码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!