1

Schema.org为 Web 中的每个有用内容提供了一个模式。例如,在这里您可以找到“食谱”的架构。正如您所看到的,有几个属性应该是文本(参见例如recipeCategory)。但是,有些属性可以包含 html img标签,例如recipeInstructions应该包含文本和视觉说明。您认为在预期为文本的属性中包含图像是否正确?在实践中,您认为以下代码是否正确:

<div itemprop="recipeInstructions">
  <p>Preheat the oven to 350 degrees. Mix in the ingredients in a bowl.</p> 
  <img src="path" title="Mixed ingredients">
  <p>Add the flour last. Pour the mixture into a loaf pan and bake for one hour.</p>
</div>

或下一个:

<div itemprop="recipeInstructions">
  <p>Preheat the oven to 350 degrees. Mix in the ingredients in a bowl.</p> 
  <p>Add the flour last. Pour the mixture into a loaf pan and bake for one hour.</p>
</div>

而且,对搜索引擎有哪些影响?

4

1 回答 1

1

<img>而言,第一个标记很好。

微数据规范中,跨度元素上 itemprop 的值是跨度的textContent.

textContentDOM4中定义为

上下文对象的所有文本节点后代的数据连接,按树顺序排列。

因此,由于<img>不是文本节点,并且没有文本节点后代,因此为了建立 itemprop 的值,它被简单地忽略。

没有理由相信关注微数据的搜索引擎不会遵循这里的规范。


As an aside, though, it's not valid to put <p> elements inside <span> elements. You may wish to fix that by using a <div> instead. The value of the itemprop would not be affected by making that change.

于 2012-05-29T12:39:05.167 回答