itemtype必须单独写在同一元素上,不可多个共存;每个实体需独立声明itemscope+itemtype;嵌套类型须紧贴对应itemprop;类型必须匹配属性定义,且大小写敏感。

itemtype 写在同一元素上才能避免嵌套冲突
多个 itemtype 不能共存于一个元素,否则解析器会直接报错或静默丢弃。常见错误是试图在一个 <section> 上同时声明 itemtype="https://schema.org/Article" 和 itemtype="https://schema.org/Person"——这在语法上非法,浏览器不报错但 Google Rich Results Test 会标红。
正确做法是拆开作用域:
- 主内容用
<article itemscope itemtype="https://schema.org/Article"> - 作者信息单独包一层:
<div itemprop="author" itemscope itemtype="https://schema.org/Person"> - 别把
itemprop="author"和itemscope itemtype="https://schema.org/Person"分开写在不同层级
同一页面多个同类实体必须独立声明 itemscope
比如页面上有三篇博客,不能只在外层套一个 <main itemscope itemtype="https://schema.org/BlogPosting"> 然后堆内容——Google 只识别第一个,其余两篇的 itemprop 全部归属失败。
每个实体都要有自己完整的 itemscope + itemtype 容器:
立即学习“前端免费学习笔记(深入)”;
<article itemscope itemtype="https://schema.org/BlogPosting">…</article><article itemscope itemtype="https://schema.org/BlogPosting">…</article><article itemscope itemtype="https://schema.org/BlogPosting">…</article>
复用 <article>、<section> 这类语义标签比全用 <div> 更安全,也避免因容器无含义引发的解析歧义。
嵌套 itemtype 必须紧贴 itemprop 才不被丢弃
地址、作者、评论者这类复合属性,必须让 itemscope itemtype 直接落在带 itemprop 的元素上。隔一层就等于断连。
使用 PptxGenJS 和 Python 解析,将结构化的 HTML/CSS 幻灯片内容转换为原生、可编辑的 PowerPoint(.pptx)演示文稿。
典型错误写法:
<div itemprop="address">
<div itemscope itemtype="https://schema.org/PostalAddress">
<span itemprop="streetAddress">建国路1号</span>
</div>
</div>
上面这段,itemprop="address" 没绑定到任何 itemscope,整个地址块会被忽略。
正确写法(紧贴):
<div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress"> <span itemprop="streetAddress">建国路1号</span> </div>
同理,itemprop="author" 必须和 itemscope itemtype="https://schema.org/Person" 在同一个 <div> 或 <span> 上。
类型选错比漏写更危险:itemtype 不匹配会导致 itemprop 失效
写对了 itemscope 和 itemprop,但 itemtype 类型不支持该属性,照样白搭。比如在 itemtype="https://www.php.cn/link/54896249c59acd568ee071229d0883c9" 下写 itemprop="price",Google 会直接跳过——因为 Event 类型没定义 price 字段。
验证前务必确认三点:
- 去 https://www.php.cn/link/54896249c59acd568ee071229d0883c9 页面查“Known properties”列表,确认你要用的
itemprop是否在其中 - 避免用基类硬套:比如
LocalBusiness支持priceRange,但Organization不支持;餐厅优先用Restaurant - 大小写敏感:
itemprop="name"✅,itemprop="Name"❌
最常被忽略的是嵌套类型里的字段完整性——比如 PostalAddress 缺 addressCountry,地图功能大概率失效,但 HTML 本身完全合法。


















