0

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?

unor
  • 92,415
  • 26
  • 211
  • 360
user3307827
  • 556
  • 1
  • 7
  • 20

2 Answers2

3

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

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • I changed The webpage to HTML5 but I think I can use a meta instead – user3307827 Mar 10 '14 at 09:54
  • @user3307827: Yes, when using HTML5, you can use [`meta` and `links` elements with Microdata in the `body`](http://webmasters.stackexchange.com/a/55133/17633). If not used with Microdata/RDFa, they are only allowed in the `head`. – unor Mar 10 '14 at 10:13
0

Assuming the top line is correct, you can just swap time for span, leaving the rest alone.

Where are you using HTML that the parser breaks on additional attributes/elements?

Rich Bradshaw
  • 71,795
  • 44
  • 182
  • 241