如果我在体内放置一个 xmlns:f="foo" 会发生什么?
What happens, if I place a xmlns:f="foo" inside the body?
假设这个 HTML5 页面:
<!DOCTYPE html>
<html>
<head><!-- some content --></head>
<body>
<div id="a" xmlns:f="http://exampleurl.jp/">
<a href="#">test</a>
</div>
</body>
</html>
这个问题包括这样一个事实,即命名空间 f
未在文档中使用,并且 http://exampleurl.jp/
不可访问。
浏览器会...
- 准备好在 div
#a
(最佳情况) 中使用该命名空间
- 忽略名称空间定义(我同意)
- 失败,因为
http://exampleurl.jp/
不可访问 (404) 或至少不包含有效的 XML 命名空间定义(最坏情况)
... ?
并且无论浏览器的实际行为如何,它们应该如何表现(根据定义)?
浏览器将忽略该属性。根据 http://www.w3.org/TR/html5/syntax.html#elements-0 this XML like syntax for defining namespace aliases (in your example, making f an alias for the namespace http://exampleurl.jp/) 不支持。
在任何情况下,名称空间 URI 都不必实际映射到实际网站上的任何内容。 URI 可以是任何东西,因为它只是用来区分相同但在不同命名空间中的本地名称。
假设这个 HTML5 页面:
<!DOCTYPE html>
<html>
<head><!-- some content --></head>
<body>
<div id="a" xmlns:f="http://exampleurl.jp/">
<a href="#">test</a>
</div>
</body>
</html>
这个问题包括这样一个事实,即命名空间 f
未在文档中使用,并且 http://exampleurl.jp/
不可访问。
浏览器会...
- 准备好在 div
#a
(最佳情况) 中使用该命名空间
- 忽略名称空间定义(我同意)
- 失败,因为
http://exampleurl.jp/
不可访问 (404) 或至少不包含有效的 XML 命名空间定义(最坏情况)
... ?
并且无论浏览器的实际行为如何,它们应该如何表现(根据定义)?
浏览器将忽略该属性。根据 http://www.w3.org/TR/html5/syntax.html#elements-0 this XML like syntax for defining namespace aliases (in your example, making f an alias for the namespace http://exampleurl.jp/) 不支持。
在任何情况下,名称空间 URI 都不必实际映射到实际网站上的任何内容。 URI 可以是任何东西,因为它只是用来区分相同但在不同命名空间中的本地名称。