When marking-up dates in HTML5, I know for a single date you should use the <time>
tag as follows
<time datetime="2011-04-02">2nd April 2011</time>
But how would you (or should you) markup a date range like "2nd - 4th April 2011"?
Thanks.
The <time> tag defines a specific time (or datetime). The datetime attribute of this element is used translate the time into a machine-readable format so that browsers can offer to add date reminders through the user's calendar, and search engines can produce smarter search results.
The <time> HTML element represents a specific period in time. It may include the datetime attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders. It may represent one of the following: A time on a 24-hour clock.
Use the <time> tag to add date and time. The HTML <time> tag is used for displaying the human readable date and time.
Marking up date ranges has yet to be settled at this point. (You can see the evolving discussion on date ranges on the WhatWG site.)
Your best bet for now is to simply use the ISO 8601 syntax for date ranges as the datetime value in a time tag. In short, just separate the two values with a forward slash.
For example, the 2nd to the 4th of April, 2011 would be:
<time datetime="2011-04-02/2011-04-04">2nd–4th April 2011</time>
Here's a simpler example representing 2000-2010:
<time datetime="2000/2010">2000–2010</time>
Remember to use an En dash between your dates for proper presentation.
It would be nice if <time>
had a nice way of representing ranges, but you have to do something like this instead:
<time datetime="2011-04-02">2nd</time> - <time datetime="2011-04-04">4th April 2011</time>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With