更正 HTML5 (+ schema.org) 标记文章的发布日期和位置
Correct HTML5 (+ schema.org) mark up for an article's publication date and location
HTML <time>
元素表示 24 小时制时间或公历中的精确日期(带有可选的时间和时区信息)。
例如:
<q>All is quiet on <time datetime="2018-01-01 00:00">New Year's Day</time></q>
考虑到这一点,<time>
似乎是给出 文章发布日期和时间的明显标记:
<article itemscope itemtype="http://schema.org/Article">
<h2>Article Heading Here</h2>
<time datetime="2017-10-30" itemprop="datePublished">October 30th, 2017</time>
<p>Article Here</p>
</article>
尽管如此,文章通常会在发布日期和时间旁边给出报告位置。
但是对于 <time>
.
,声明的地理位置似乎是不合适的内容
所以...如何最好地标记信息:
哈德斯菲尔德 • 2017 年 10 月 30 日
到目前为止,我最喜欢的方法是使用 HTML5 data-*
元素,通过 CSS ::before
伪元素显示:
工作示例:
time::before {
content: attr(data-location) '[=14=]a0[=14=]a022[=14=]a0[=14=]a0';
}
<time datetime="2017-10-30" itemprop="datePublished" data-location="Huddersfield">October 30th, 2017</time>
但是是否有更语义化的方法(使用 schema.org 微数据等)?
作为 dateline is typically used for news articles, Schema.org defines a dateline
property only for NewsArticle
(Article
的子类型):
A dateline is a brief piece of text included in news articles that describes where and when the story was written or filed though the date is often omitted. Sometimes only a placename is provided.
它需要一个文本值。
微数据中的示例
日期线由地名和日期组成(假设发布日期为日期"when the story was written or filed"):
<p itemprop="dateline">
Huddersfield • <time datetime="2017-10-30" itemprop="datePublished">October 30th, 2017</time>
</p>
日期线仅包含地名:
<p>
<span itemprop="dateline">Huddersfield</span> • <time datetime="2017-10-30" itemprop="datePublished">October 30th, 2017</time>
</p>
HTML <time>
元素表示 24 小时制时间或公历中的精确日期(带有可选的时间和时区信息)。
例如:
<q>All is quiet on <time datetime="2018-01-01 00:00">New Year's Day</time></q>
考虑到这一点,<time>
似乎是给出 文章发布日期和时间的明显标记:
<article itemscope itemtype="http://schema.org/Article">
<h2>Article Heading Here</h2>
<time datetime="2017-10-30" itemprop="datePublished">October 30th, 2017</time>
<p>Article Here</p>
</article>
尽管如此,文章通常会在发布日期和时间旁边给出报告位置。
但是对于 <time>
.
所以...如何最好地标记信息:
哈德斯菲尔德 • 2017 年 10 月 30 日
到目前为止,我最喜欢的方法是使用 HTML5 data-*
元素,通过 CSS ::before
伪元素显示:
工作示例:
time::before {
content: attr(data-location) '[=14=]a0[=14=]a022[=14=]a0[=14=]a0';
}
<time datetime="2017-10-30" itemprop="datePublished" data-location="Huddersfield">October 30th, 2017</time>
但是是否有更语义化的方法(使用 schema.org 微数据等)?
作为 dateline is typically used for news articles, Schema.org defines a dateline
property only for NewsArticle
(Article
的子类型):
A dateline is a brief piece of text included in news articles that describes where and when the story was written or filed though the date is often omitted. Sometimes only a placename is provided.
它需要一个文本值。
微数据中的示例
日期线由地名和日期组成(假设发布日期为日期"when the story was written or filed"):
<p itemprop="dateline">
Huddersfield • <time datetime="2017-10-30" itemprop="datePublished">October 30th, 2017</time>
</p>
日期线仅包含地名:
<p>
<span itemprop="dateline">Huddersfield</span> • <time datetime="2017-10-30" itemprop="datePublished">October 30th, 2017</time>
</p>