SDTT显示'问题',但不显示'答案'

问题描述 投票:0回答:1

对于常见问题解答,我尝试将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>
html5 schema.org microdata
1个回答
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。)

© www.soinside.com 2019 - 2024. All rights reserved.