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

Igo*_*gor 3 html xhtml w3c-validation

我试图将我的文档验证为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>
Run Code Online (Sandbox Code Playgroud)

怎么解决这个问题?

谢谢!

Dmy*_*bak 5

不幸的是,这是不可能的,因为http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd对这些属性一无所知(itemscope,itemtype).您可以通过将该文件下载到您的计算机并尝试查找(Ctrl + F)单词itemscopeitemtype在该文档中来说服自己.你将得到0结果.

所以基本上,你从这里开始有两个选择:

  1. 如果您想继续使用itemscopeitemtype属性您必须切换到HTML5 doctype,那么您的文档将如下所示:

    <!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>
    
    Run Code Online (Sandbox Code Playgroud)

这将导致:

This document was successfully checked as HTML5!

  1. 如果您需要保留XHTML文档类型定义,那么您必须从微数据切换到RDF,您的文档将如下所示:

    <!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>
    
    Run Code Online (Sandbox Code Playgroud)

这将导致:

This document was successfully checked as -//W3C//DTD XHTML+RDFa 1.1//EN!