我无法让我的网站在 W3C 标记验证中进行验证。
这是验证错误之一的示例。
Error: Attribute xmlns:content not allowed here.
我做了一些研究,一些文章建议我们更改:
xmlns:name="http://url" syntax into the prefix="name:http://url"
但是我有多个 xmlns 属性。
不知道在这种情况下如何编写前缀。
原文:
`<html lang="en" dir="ltr"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:og="http://ogp.me/ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:sioc="http://rdfs.org/sioc/ns#"
xmlns:sioct="http://rdfs.org/sioc/types#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#">`
每个属性之间是否用空格分隔?
<html lang="en" dir="ltr" prefix="content:http://purl.org/rss/1.0/modules/content/ dc:http://purl.org/dc/terms/ foaf:http://xmlns.com/foaf/0.1/">
或者我们应该用
\n
换行来分隔?您不能使用 HTML 5 中任意命名空间中的元素。为此,您需要使用 XML,并且为了进行验证,您需要一个合适的 DTD 或架构,其中包含您想要使用的所有命名空间。
您需要在 html 标记之前放置一个文档类型。您可以使用:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
网页包含 RDFa 标记,这是 HTML 5 中允许的。HTML+RDFa 1.1 规范有 专门用于
@xmlns:
属性的部分。
它表示 RDFa 1.1 中已弃用
@xmlns:
的使用,但仍允许向后兼容。因此,如果可能的话,不应该使用它。然后,以下关于 @xmlns 的一致性标准:-前缀属性 的部分指出:
对于符合本规范的文档,名称中具有与“
”匹配的不区分大小写的前缀的属性必须被视为符合。一致性检查器应该接受具有与“@xmlns:
”匹配的不区分大小写前缀的属性名称作为一致性。一致性检查器应该生成警告,指出不推荐使用@xmlns:
。一致性检查器可能会将@xmlns:
的使用报告为错误。xmlns:
我知道 W3C HTML 验证器正在采用更严格的一致性检查,其中
xmlns:
被报告为错误,尽管我觉得很奇怪,因为它应该生成警告。
版本已过时。并且需要使用生物识别技术进行简单的验证。