SDTT显示“问题”,但不显示“答案”

时间:2019-03-13 16:03:59

标签: html5 schema.org microdata

对于FAQ,我尝试结合使用HTML,WAI-ARIA和微数据(使用Schema.org),但是SDT​​T验证仅显示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>

1 个答案:

答案 0 :(得分:0)

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

这样做的原因是您没有将Answer添加到Question,而是添加到了父项(您的代码段中缺少该项)。

具有div属性的acceptedAnswer必须是具有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>

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