Description

The HTML element <time> is used to define a specific time or DateTime, like birthdays and anniversaries.

The attribute datetime can be used to translate the time into a machine-readable format, which can be used by browsers and search engines as below.

  • The browsers can use them to add date reminders to the user's calendar.
  • The search engines can use them to produce smarter search results.

The below table summarizes its usage.

Usage Details
Placement It is displayed as an Inline element.
Contents It can contain Inline elements and text, but cannot use <time>.
Tags Both the opening and closing tags are required.
Versions HTML 5

Syntax

Here is the basic syntax of the <time> element.

<time>...</time>

Examples

Run this on IDE

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example - HTML Element time</title>
</head>
<body>
    <p>The food court opens from <time>10:00</time> to <time>21:00</time> everyday.</p>
    <p>I have a date on <time datetime="2010-12-14 19:00">Valentines day</time>.</p>
</body>
</html>

Attributes

The following table shows the list of supported and unsupported attributes for the <time> element.

Attribute Type Details
Element-Specific Attributes The tag <time> has some element-specific attributes listed in the below table.
Global Attributes Like all other HTML tags, the tag <time> supports the HTML Global Attributes.
Event Attributes The tag <time> also supports the HTML Event Attributes.

Here is a list of attributes that are specific to the <time> element.

Attribute Value Required Description
datetime DateTime No Specifies the date and/or time that the element represents.

Browser Compatibility

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

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

Related Links