HTML5 “time” Tag

Advertise Here

,

The “time” tag is used to represent date/time combination. Examples:

<footer>Published <time pubdate datetime="2011-07-03">07/03</time>.</footer>
I need this <time datetime="2011-07-03T12:28:57-07:00">now</time>!
Captain's log, date <time>2011-07-03T12:51:02-07:00</time>.

Note: if you do not include the “datetime” attribute, then your “time” tag's content must follow the same format used by the “datetime” attribute.

“datetime” Attribute

“datetime” attribute encodes the precise date or date/time. The format must be exact, and must include at least “yyyy-mm-dd”. (time info is optional) Examples:

… mom's birthday <time datetime="2011-07-03">July 3rd</time> …
… had piano lesson at <time datetime="2011-07-03T13:00">1 pm</time> …
… the bomb went off at <time datetime="2011-07-03T12:46:03-07:00">12:46:03 PST</time> …

The “datetime” attribute is optional. But if not present, then the “time” tag's content must use the the same fomat used by “datetime” attribute. e.g. yyyy-mm-ddThh:mm:ss-hh:mm.

Sample Correct Formats

Wrong Examplez

“pubdate” Attribute

“pubdate” boolean attribute can be included. If present, that means your time tag represent the time your article is published. Example:

<time pubdate>2011-07-03T13:05:28-07:00</time>
<time pubdate datetime="2011-07-03T13:05:28-07:00">July 03</time>

Note that “pubdate” does not take any values. It is wrong to say pubdate="…".

Back to HTML5 Tags.

blog comments powered by Disqus