HTML and CSS Reference
In-Depth Information combines a relative time (“8 hours ago”) as the text
content of the element, with a title attribute showing the human-
readable full time on hover:
<p>Submitted <time title=”Sun Jul 3 02:15:49 2011 GMT”
¬ datetime=”2011-07-03T02:15:49.881631+00:00”>8 hours</time>
¬ ago</p>
The only trouble with <time> is that it must contain a positive
date on the proleptic Gregorian calendar—meaning you can't
encode a date before the Christian era. Neither can you encode
imprecise dates such as “July 1904.” This seriously limits its use
for sites such as museums, history/encyclopedia pages, or fam-
ily trees, where precise dates may not be known.
A consortium of search engines, Bing, Google, and Yahoo!, has
launched an initiative called to create and support a
series of common markup patterns. This growing set of schemas
use HTML5 Microdata (see later in this chapter):
“ . . . in ways recognized by major search providers. Search
engines including Bing, Google and Yahoo! rely on this markup
to improve the display of search results, making it easier for
people to find the right web pages ( ).”
Note that uses the <time> element to express dates,
but uses the full ISO 8601 date format rather than HTML5's cut-
down date format, so “2011-09” is a legitimate date, expressing
an unspecified day in September 2011. Similarly, durations can
be specified via a “P” prefix (for period):
<time itemprop=”cookTime” datetime=”PT1H30M”>1.5 hours</time>
As we've seen, neither of these examples have
datetime attributes that will validate as HTML5. This puts
responsible developers in a quandary—should you aim for the
personal karma of valid code, or the tangible business benefits
of helping search engines understand your content?
It's silly to force developers to choose, so hopefully the Work-
ing Group will see sense and loosen the restrictions on the
<time>  element.
NoTE As this second
edition goes to press, the
Working Group is discussing
removing <time> from HTML
and, to replace it, magicking up
a more generic—and therefore
less useful— <data> element.
We hope that this won't happen
but before you use it, please
to ind any errata to this topic.
Or look at the spec!
The pubdate attribute
The Boolean attribute pubdate indicates that this particular
<time> is the publication date of an <article> or the whole
<body> content.
Search WWH ::

Custom Search