<time> HTML Tag

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
What does <time> HTML Tag do?
Defines a datetime. The content of a time element is typically a human-readable date and time, and a machine-readable version of the same time is placed in the datetime attribute.
Display
inline

Code Example

<p>Intro to Web Design begins <time datetime="2016-08-09 08:00">Tuesday at 8:00 AM</time> in room 3.</p>

Intro to Web Design begins in room 3.

In that code example, the time element tells the browser that the text “Tuesday at 8:00 AM” is a reference to time. The datetime element is not shown to the user but is used by the browser to relay the same information as what is contained in the text content of the time element.

Using time

The time element is used to tell a browser that the associated text is time-related. In-and-of itself, that doesn’t do a lot for users or browsers, although it may be a help to users of some assistive technologies. The time element isn’t particularly useful until paired with a datetime attribute. One a datetime attribute has been associated with the time element, the browser knows a lot more about the time described in the time element and can use that information when interacting with other applications — such as when importing information from an HTML email or webpage into a calendar application.

The datetime attribute can be used to identify a year, a month and year, a specific date, a date and time, a time without a date, and durations of time.

Adam is a technical writer who specializes in developer documentation and tutorials.