对于FAQ,我尝试结合使用HTML,WAI-ARIA和微数据(使用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>
答案 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
。)