用于添加自定义注释数据的语义HTML元素

问题描述 投票:4回答:3

假设我有一个我想注释的HTML段落(即添加一些不应显示的上下文,只需在文本中添加含义)

<p>The ultimate measure of a man is not where he stands 
in moments of <tag data="some custom annotation">comfort and convenience</tag>,
but where he stands at times of challenge and controversy.</p>

在这种情况下应该使用什么正确的语义标记?

html semantic-web schema.org rdfa
3个回答
1
投票

3c。缺少/隐含信息:将meta标签与内容一起使用

有时,网页上包含的信息可能会很有价值,向上,但由于信息的方式而无法对其进行标记出现在页面上。信息可以图像形式传达(用于例如,用于表示评分为4分(满分5分)的图片或Flash对象(例如,视频剪辑的持续时间),也可能是暗示但未在页面上明确说明(例如,价格的货币)。

在这种情况下,请使用meta标记以及content属性来指定信息。考虑这个示例,该图像向用户显示了一个5星评级4星:

<div itemscope itemtype="http://schema.org/Offer"> <span itemprop="name">Blend-O-Matic</span> <span itemprop="price">$19.95</span> <img src="four-stars.jpg" /> Based on 25 user ratings </div>

这里再次是示例,其中标记了评分信息。

<div itemscope itemtype="http://schema.org/Offer">
  <span itemprop="name">Blend-O-Matic</span>
  <span itemprop="price">$19.95</span>
  <div itemprop="reviews" itemscope itemtype="http://schema.org/AggregateRating">
    <img src="four-stars.jpg" />
    <meta itemprop="ratingValue" content="4" />
    <meta itemprop="bestRating" content="5" />
    Based on <span itemprop="ratingCount">25</span> user ratings
  </div>
</div>

应谨慎使用此技术。仅将带有内容的元数据用于否则无法标记的信息。


1
投票
都具有similar capabilities,并且被搜索引擎搜寻器理解。也就是说Google支持Microdata。

有关准备使用的示例,您可以参考schema.org website。每个术语定义均显示两种序列化的用法。您的HTML可能是:

微数据

<p itemscope itemtype="http://schema.org/Person"> The ultimate measure of a man is not where he stands in moments of <span itemprop="description">comfort and convenience</span>, but where he stands at times of challenge and controversy. </p>

RDFa

<p vocab="http://schema.org/" typeof="Person">
  The ultimate measure of a man is not where he stands in moments of 
  <span property="description">comfort and convenience</span>,
  but where he stands at times of challenge and controversy.
</p>

您可以看到,我只是使用<span>来封装带注释的文本。其他方面RDFa和Microdata没什么不同。
也请查看RDF Translator app。它将帮助您摆弄注释。


© www.soinside.com 2019 - 2024. All rights reserved.