The HTML5 <time> tag

The <time> tag is another newly introduced HTML5 element. It defines extra semantic information like time (24 hour format) or date (with or without time zone offset) in a web page. The <time> element of HTML5 does not render anything, so it won’t make any difference in the output. But it encodes the date and time in a way that can be read by web browsers and generates smarter search results produced by search engines.

Web browser support:

HTML5 <time> tag is supported by latest versions of all web browsers. Internet Explorer 8 or earlier versions of Internet Explorer do not support this element.

There is a HTML5 <time> element example given below:

Our shop is opened at <time>10:00</time> every morning.

When this tag is used without any attributes then the content enclosed between <time> and </time> must be a valid date or time.

The HTML5 <time> element has an attribute ‘datetime’. In the following examples, I would like to show that how to use ‘datetime’ attribute with this element.

<time datetime="2012-11-25">25<sup>th</sup> November</time>
<time datetime="18:00">starts at 6pm</time>
<time datetime="2012-11-25T18:00+00:00">6pm on the festival day</time>

When the datetime attribute is used with the <time> tag then content can be anything.

Leave a Reply

Your email address will not be published. Required fields are marked *

6 − four =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>