The time element

The time tag (<time>) 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.

Important point need to be remembered:

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

There is an example of HTML5 time element given below:

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

When <time> 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 in the time 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 HTML5 time element, that time the content can be anything.

Press CTRL+D to bookmark this page - The time element

2 Responses to <time>

  1. Shivani says:

    Good for beginners. Suggestion: Show all the output in web page. Thanks:)

  2. Ulfat says:

    Thank you sir. It’s a great article.

Your comment


4 + 5 =