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

标签 html semantic-web schema.org rdfa

假设我有一个 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>

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

最佳答案

这个案例有一个特定的标签,在不显示内容的情况下指定语义。这是通过具有 itempropcontent 属性的 meta 标签完成的,并且在 schema.org 的入门部分中有很好的解释。 :

3c. Missing/implicit information: use the meta tag with content

Sometimes, a web page has information that would be valuable to mark up, but the information can't be marked up because of the way it appears on the page. The information may be conveyed in an image (for example, an image used to represent a rating of 4 out of 5) or a Flash object (for example, the duration of a video clip), or it may be implied but not stated explicitly on the page (for example, the currency of a price).

In these cases, use the meta tag along with the content attribute to specify the information. Consider this example—the image shows users a 4 out of 5 star rating:

<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>

Here is the example again with the rating information marked up.

<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>

This technique should be used sparingly. Only use meta with content for information that cannot otherwise be marked up.

关于html - 用于添加自定义注释数据的语义 HTML 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34894401/

相关文章:

json - 为什么 JSON-LD 中需要在上下文之后指定类型?

seo - 什么是 `&lt;script type=' application/ld+json'>{jsonObj}</script >` in a ` head` 部分?

html - 问答页面的架构标记

iphone - iOS 邮件客户端中的间歇性图像链接行为

javascript - 是否可以使用 MongoDB 作为 html 项目的数据库?

sparql - 如何在 SPARQL 构造查询中递归扩展空白节点?

semantic-web - 在 OWL 中声明一个空类

Android HTML5 视频 - 单击播放时有效,但不是 video.play()

javascript - 获取表中自定义属性的每个值

rdf - 如何获取sparql查询结果的所有解引用链接