HTML and CSS Reference
In-Depth Information
We still need to add a
date to the blog…
Did you notice in our blog design that we
added a date to every blog post? Before
HTML5, dates were created in an ad hoc
way—you might have just added the date
without marking it up at all, or used a
<span>
or even a
<p>
to mark it up. But now, we
have an element that's perfect for the job: the
<time>
element.
A two-minute guide to the <time> element
Let's take a closer look at the <time> element. It has an important
attribute, datetime, and the element's kind of picky about the values you
use in this attribute, so it's worth going over some of the details.
T
he dat
etime
attribu
te is re
quired
if the c
ontent
of the
elemen
t isn't
written
using t
he off
icial Int
ernet
date/t
ime for
mat.
<time datetime="2012-02-18">
2/18/2012
</time>
This
is the
official
Intern
et form
at
for
specifyi
ng date
s with
a day,
mont
h, and
year.
You c
an specify just a year
and month,
or ev
en just a year.
2012-02
2012
You can add on
a time, in
24-hour form
at.
2012-02-18 09:00
Here are some other ways to
express dates and times using
the official format.
2012-02-18 18:00
You can s
pecify just a time.
If you use a “Z”
after
the date and tim
e, then it
means UTC time
.
05:00
2012-02-18 05:00Z
(UT
C = G
MT)