在HTML5 for HTML4中使用微数据日期时间的替代方法 [英] Alternative method for using Microdata datetime in HTML5 for HTML4

查看:133
本文介绍了在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属性.也没有定义timedata元素.有些人会滥用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).

这篇关于在HTML5 for HTML4中使用微数据日期时间的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆