有效的XHTML:"itemscope"不是为任何属性指定的组的成员

4

我正在尝试将我的文档验证为XHTML 1.0 Transitional(W3C)。我遇到了以下错误:

"itemscope"不是为任何属性指定的组的成员

这对应于以下代码:

<body class="innerpage" itemscope itemtype="http://schema.org/Physician">

<body class="innerpage" itemscope itemtype="http://schema.org/Physician">
<!-- Facebook Conversion Code for Leads -->
<script type="text/javascript" src="js/face.js"></script>
   </body>
</html>

这个问题怎么解决?

谢谢!


生命太短暂,无需让每一页都合法有效,放松一点。 - Alex
你必须使用XHTML文档类型吗?还是可以切换到HTML5? - pwdst
在检查此文档作为XHTML 1.0 Transitional时发现错误!DOCTYPE html PUBLIC“ -//W3C // DTD XHTML 1.0 Transitional” - Igor
1个回答

6
很遗憾,这是不可能的,因为http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd对于那些属性(itemscope、itemtype)一无所知。您可以通过下载该文件到您的电脑并在文件中查找(Ctrl+F)单词itemscopeitemtype来自行验证,您会得到0个结果。
所以,基本上从这里开始,您有两个选择:
  1. If You want to continue using itemscope and itemtype attributes You have to switch to HTML5 doctype, then your document would look like as follows:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body class="innerpage" itemscope itemtype="http://schema.org/Physician">
    <p>Content</p>
    </body>
    </html>
    
这将会导致: 此文档已成功检测为HTML5!
  1. If You need to preserve XHTML Document Type Definition, then You have to switch from microdata to RDF and Your document will look the following:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN"
        "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body class="innerpage" vocab="http://schema.org/" typeof="Physician">
    <p>Content</p>
    </body>
    </html>
    
这将导致以下结果:

此文档已成功检查为-//W3C//DTD XHTML+RDFa 1.1//EN!


1
如果代码嵌入到列表中,您需要使用八个空格缩进每行代码。我已经为您修复了格式。 - BoltClock
我已经编辑了你的帖子 - 不需要再做任何事情了。 "回滚" 意味着完全撤销编辑。 - BoltClock

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接