How do you markup a date range with the HTML5 time tag?
When m开发者_运维技巧arking-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.
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>
精彩评论