【问题标题】:Connect two microdata items that are not in the same scope连接两个不在同一范围内的微数据项
【发布时间】:2012-08-21 09:47:57
【问题描述】:

假设我的 html 页面如下所示:

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

<span itemprop="name">My Video Name</span>

</div>

...页面的其余部分...

<textarea rows="7" cols="54" readonly="readonly"><?php echo $embedUrl?></textarea>

我想为 textarea 添加一个 itemprop="embedUrl" 因为它包含我的视频对象的嵌入代码,但由于它不在我的 div 中,因为这是页面的设计方式,所以我必须创建一个新的videoobject 以指定它。如何扩展原始视频对象的范围以包含文本区域,即使它不在原始 div 中?

【问题讨论】:

    标签: html seo microdata rich-snippets


    【解决方案1】:

    您的用例是 itemref 属性的用途。

    你可以这样使用它:

    <div itemscope itemtype="http://schema.org/videoObject" itemref="mytextarea">
        <span itemprop="name">My Video Name</span>
    </div>
    

    ...页面的其余部分...

    <textarea rows="7" cols="54" readonly="readonly" 
        id="mytextarea" itemprop="embedUrl"><?php echo $embedUrl?></textarea>
    

    itemref 属性必须与itemscope 属性位于同一元素上,并采用空格分隔的具有 itemprop 属性的元素的 id 列表。

    欲了解更多信息,请查看HTML5 Doctor article on microdata

    【讨论】:

    • 很棒的文章,比 schema.org 或 Google 的页面解释得更好...谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多