【问题标题】:SDTT shows the 'Question', but not the 'Answer'SDTT 显示“问题”,但不显示“答案”
【发布时间】:2019-08-04 09:23:04
【问题描述】:

对于一个常见问题解答,我尝试结合 HTML、WAI-ARIA 和 Microdata(使用 Schema.org),但 SDTT 验证只显示 Question,而不是 Answer

<section class="accordion" role="tablist" aria-live="polite">
    <details>
        <summary aria-controls="panel0" role="tab" itemprop="mainEntity" itemscope itemtype="https://schema.org/Question">
            <p temprop="name">How to beat the boss...spoiler alert !</p>
            <meta itemprop="answerCount" content="1"/>
        </summary>
            <div itemprop="acceptedAnswer" itemscope itemtype="https://schema.org/Answer">
                <p aria-labelledby="tab0" role="tabpanel" itemprop="text"> Just aim to the red spots near his eyes Keep shooting at these spots until the eyes open, then hit quickly both eyes with your laser beam.</p>
           </div>
    </details>
</section>

【问题讨论】:

    标签: html schema.org microdata


    【解决方案1】:

    SDTT 显示 Answer,但它与 Question 处于同一级别(因此它们没有关联)。

    原因是您没有将Answer 添加到Question,而是添加到父项(您的sn-p 中缺少该项)。

    带有acceptedAnswer 属性的div 必须是带有Question 的元素的子元素。如果您的标记无法做到这一点(因为 Answer 不应该是 summary 元素的一部分),您可以使用 Microdata 的 itemref 属性:

    <details>
    
      <summary aria-controls="panel0" role="tab" itemprop="mainEntity" itemscope itemtype="https://schema.org/Question" itemref="answer">
        <p temprop="name">How to beat the boss...spoiler alert !</p>
        <meta itemprop="answerCount" content="1"/>
      </summary>
    
      <div id="answer" itemprop="acceptedAnswer" itemscope itemtype="https://schema.org/Answer">
        <p aria-labelledby="tab0" role="tabpanel" itemprop="text"> Just aim to the red spots near his eyes Keep shooting at these spots until the eyes open, then hit quickly both eyes with your laser beam.</p>
      </div>
    
    </details>
    

    (我在Question 中添加了itemref="answer",在Answer 中添加了id="answer"。)

    【讨论】:

      猜你喜欢
      • 2013-02-26
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多