HTML5 <time> Tag

Topic: HTML5 Tags Reference« Prev|Next »

Description

The <time> element represents a time and/or date.

This element is intended as a way to encode dates and times in a machine-readable format, so that user agents can offer to add event reminders such as birthdays and anniversaries, or any event scheduling for user's calendar.

The following table summarizes the usages context and the version history of this tag.

Placement: Inline
Content: Inline and text, but no descendant <time> elements
Start/End Tag: Start tag: required, End tag: required
Version: New in HTML5

Syntax

The basic syntax of the <time> tag is given with:

HTML / XHTML: <time> ... </time>

The example below shows the <time> tag in action.

  • <p>The library opens at <time>8:30 am</time> every morning.</p>
  • <p>The concert took place on <time datetime="2016-12-31 12:00">31 Dec</time>.</p>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <time> tag.

Attribute Value Description
datetime datetime Specifies the time or date that the element represents.

Global Attributes

Like all other HTML tags, the <time> tag supports the global attributes in HTML5.


Event Attributes

The <time> tag also supports the event attributes in HTML5.


Browser Compatibility

The <time> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 4+
  • Google Chrome 6+
  • Internet Explorer 9+
  • Apple Safari 5+
  • Opera 11.1+

Further Reading

See tutorial on: HTML Text Formatting.

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.