What’s the point of using the HTML5 <time> tag?

I have been going through some tutorials on the <time> tag, but I honestly don't see why we are using it.

For example:

Published <time pubdate datetime="2011-07-03">07/03</time>

If we are going to have a string 07/03 anyway, what is the purpose of using a time tag? It doesn't validate anything.


Solution 1:

The point of this tag, as with a number of the new "semantic" HTML5 tags, is to make it easier for programs to index your data.

A script can go through and easily find out what the published date is for your blog articles if it sees a <time> tag, without having to parse any of a number of ways this could be represented (for consumption by a human being), which would be a much more complex and error-prone task.

Solution 2:

It's in a machine-readable format, so any script or search engine reading your content can understand the date/time of publication. That way you can format it in a nice way for readers without affecting machine readability. It's covered under microformats which are a good thing.

E.g. <time pubdate datetime="2011-07-03">3 days ago</time> looks nice for humans and computers.

Solution 3:

HTML5 time element

When in doubt look at the spec!

The time element represents its contents, along with a machine-readable form of those contents in the datetime attribute. The kind of content is limited to various kinds of dates, times, time-zone offsets, and durations, as described below.

From the HTML5.2 spec on the W3C site: https://www.w3.org/TR/html52/textlevel-semantics.html#the-time-element

Have a look at the site for more info. :)

Solution 4:

The time element also has an associated DOM API that can be used. See http://my.opera.com/ODIN/blog/2011/05/31/dom-scripting-and-the-time-element and http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-time-element