gpt4 book ai didi

html - 在丰富的代码段中为 Itemscope 属性分配一个值

转载 作者:搜寻专家 更新时间:2023-10-31 08:04:02 25 4
gpt4 key购买 nike

所以我们使用了一些丰富的代码片段,他们使用了 html5 标记方案。

我们的问题是 itemscope 属性没有值。

<div itemscope itemtype="http://schema.org/LocalBusiness">

这会导致我们的旧产品 html 验证失败,因为它认为它是一个空标签。如果像这样将值 1 分配给 google 和标记规则,它们的工作原理是否相同。

<div itemscope="1" itemtype="http://schema.org/LocalBusiness">

在我们可以正确更新我们的验证方法之前,这是一个暂时的解决方案,但这是一个更远的项目。

那么基本上是否有适当的语法使它对 Google 的丰富网页摘要规则、html5 和 html5 之前的旧验证引擎仍然有效?

最佳答案

(这个答案基本上是从Peter Murray复制过来的,具体就是这些two comments。)

HTML5 规范允许 boolean attributes值为空字符串或属性名称:

If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.

所以要么这样:

<div itemscope="" itemtype="http://schema.org/LocalBusiness">

或者这个:

<div itemscope="itemscope" itemtype="http://schema.org/LocalBusiness">

是有效的 HTML5。

为了确保 Google 正确识别 itemscope="itemscope",他 (Peter Murray) 创建了一个 example page并通过 Google's rich snippet validator 运行它.来自results ,您可以看到 Google 正确地获取了数据(一个事件项)。

关于html - 在丰富的代码段中为 Itemscope 属性分配一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14488686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com