Right way to set microdata for Q&A HTML

好久不见. 提交于 2019-12-04 06:37:28
unor

From your first example, Microdata parsers will only learn that there is a Question and an Answer item, without any further content. Microdata doesn’t specify that the content of HTML elements with itemscope attributes has to be considered, it only cares about property values.

Testing your example with some online Microdata parsers:


name vs. text

For this very question, the name would be "Right way to set microdata for Q&A HTML" and the text would be the question body ("Say one has a simple question …").

If the whole question consists only of such a single, short line, I’d use the text property instead of name (*). name could, principally, also be something like "Question 1", if you want/need it.

But you could also use both properties for a short question, i.e., itemprop="name text", but this is maybe not very elegant (but it can make sense especially if you know that some data consumer makes use of the name property).

* The example for Answer also uses text (and has no name).


You might also want to use Question’s suggestedAnswer property and/or Answer’s parentItem property to relate these two items.

So for a short question it could look like:

<section itemscope itemtype="http://schema.org/Question">
  <h2 itemprop="name text">My Question</h2>
  <div itemprop="suggestedAnswer" itemscope itemtype="http://schema.org/Answer">
    <p itemprop="text">My Answer</p>
  </div>
</section>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!