Chapter 4
“November, 2019.” Furthermore, dates are limited to the modern Gregorian calendar, introduced in the 16th
century, so don’t use the time element to reference dates in the distant past unless you can accurately
convert those dates to the Gregorian calendar. It’s hard to pinpoint a date like “October 1, 2975 BCE”
because the month of October didn’t actually exist back then.
Listing 4-28 is an example of a time element indicating an article’s publication date. The datetime
attribute has a value machines can interpret, whereas the element’s text contents are intended for human
readers.
Listing 4-28. A time element indicating a precise date and time
<footer>
<p>Posted on <time datetime="2012-05-05T15:35:42-07:00">
Saturday, May 5, 2012 at 3:35 pm Pacific</time></p>
</footer>
Required Attributes
The time element doesn’t require any attributes if its contents are properly formatted.
Optional Attributes
datetime: The precise date and/or time represented, with optional time zone offset. This
attribute’s value must be a valid date string, a valid time string, or combination of the two.
In late October 2011, the WHAT Working Group announced that the time element was being removed
from their working version of the HTML5 specification, to be replaced by a new data element that would
allow for the inclusion of more general-purpose, machine-readable data beyond just dates and times.
There was a fair bit of public outcry from web developers, citing many real-world uses for encoding times
and dates in ways that the generic data element couldn’t readily serve as substitute. The decision was
quickly reversed and time was restored to the spec, though slightly revised and now lacking the pubdate
attribute.
mark
The mark element highlights a segment of text for reference, to indicate its relevance in some other
context. The element imparts no further semantic meaning to its contents; it only marks the text as a
passage of interest. For example, you might use the mark element in a block quotation to highlight the
particular part of the text you’re discussing or referencing, to focus the reader’s attention on some detail
while still including the longer quotation to preserve the original context.
It has long been common practice in journalism and academic writing to mark relevant passages with
italics or bold text, along with a disclaimer like, “emphasis added,” just to clarify for the reader that the
original text didn’t stress those phrases. On the Web, this always required some other element (usually em,
strong, i, b, or even a span), but now the authors of HTML5 have provided the mark element for just this
purpose. Listing 4-29 shows the mark element calling out one part of a longer quotation.