<time>

Anonymous contributor's avatar
Anonymous contributor
Published Nov 8, 2021Updated Nov 8, 2021
Contribute to Docs

The <time> semantic HTML element represents a time-related piece of information, including:

  • A specific date in the Gregorian calendar.
  • The time on a 24-hour clock.
  • A valid time duration. The <time> element accepts a datetime attribute that translates the info to a machine-readable format.

Syntax

<time>
<!-- Date and/or time info goes inside the tag -->
</time>

The <time> element requires opening and closing tags that wrap around a block of text.

Its datetime attribute should be in a valid format for it to be translated to machine-readable info, see below examples.

Example

Using the <time> element inside of another element:

<p>
Our flight is scheduled on
<time datetime="2021-12-20">December 20th, 2021</time> at
<time datetime="18:00">6:00pm</time>.
</p>

All contributors

Contribute to Docs

Learn HTML on Codecademy