Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
745 views
in Technique[技术] by (71.8m points)

schema.org - Alternative method for using Microdata datetime in HTML5 for HTML4

This code is for HTML5:

<time itemprop="datePublished" datetime="2012-01-07T07:07:21+00:00">January 7, 2012</time>

Can I use this code for HTML4?

<div itemprop="datePublished">
    <span dateCreated="2012-01-07T07:07:21+00:00">January 7, 2012</span>
</div>

Or something like this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Note that Microdata is specified for HTML5, not for HTML 4.01 (related question). If you don’t care about that:

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>

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...