在HTML5 for HTML4中使用微数据日期时间的替代方法
此代码适用于HTML5:
This code is for HTML5:
<time itemprop="datePublished" datetime="2012-01-07T07:07:21+00:00">January 7, 2012</time>
我可以将此代码用于HTML4吗?
Can I use this code for HTML4?
<div itemprop="datePublished">
<span dateCreated="2012-01-07T07:07:21+00:00">January 7, 2012</span>
</div>
还是类似的东西?
请注意,微数据是为HTML5指定的,而不是为HTML 4.01指定的(相关问题).如果您不在乎:
Note that Microdata is specified for HTML5, not for HTML 4.01 (related question). If you don’t care about that:
HTML 4.01没有为span
元素定义dateCreated
属性.也没有定义time
或data
元素.有些人会滥用abbr
元素,但我不建议这样做.因此,您可能必须使用span
元素,并且在丑陋的情况下为访问者隐藏机器可读的日期.
HTML 4.01 doesn’t define a dateCreated
attribute for the span
element. There is also no time
or data
element defined. Some would misuse the abbr
element, but I wouldn’t recommend that. So you’d probably have to use a span
element, and, ugly, hide the machine-readable date for your visitors.
<span><span itemprop="datePublished" class="hidden">2012-01-07T07:07:21+00:00</span> January 7, 2012</span>
但是最好不要在HTML 4.01文档中首先使用微数据.您可以改用RDFa (也可以
But better don’t use Microdata in HTML 4.01 documents in the first place. You could use RDFa instead (you can also use the Schema.org vocabulary in RDFa).