Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Inline Text

The <time> element

Reference for the HTML <time> element: human-friendly dates, times and durations with a machine-readable datetime value, valid formats, examples and details.

The <time> element marks a date, a time or a duration. The content is written for people ("next Friday", "3 hours"), while the datetime attribute gives software a precise value it can parse, such as 2026-11-20 or PT3H. Calendars, search engines, browser extensions and your own scripts can then understand the moment you mean.

HTML
<p>Doors open <time datetime="2026-11-20T19:00">Friday at 7 p.m.</time></p>

Try it

Dates, times and durations

The script reads each element's dateTime property, which mirrors the attribute. The two store-hour times have no attribute, so their text is already the machine-readable value.

Attributes

Attribute Values Description
datetime A valid date, time or duration string (see below) The machine-readable value. If it is missing, the element's text content must itself be a valid value, and the element may then contain only text.

The element also accepts the global attributes.

Valid datetime formats

Kind Example Meaning
Year 2026 A whole year
Month 2026-11 November 2026
Date 2026-11-20 One calendar day
Yearless date 11-20 November 20 in any year
Week 2026-W47 Week 47 of 2026
Time 19:00 or 19:00:30.5 A time of day, no date
Local date and time 2026-11-20T19:00 No time zone given
Global date and time 2026-11-20T18:00Z or 2026-11-20T19:00+01:00 A moment with a UTC offset
Time-zone offset +05:30 An offset on its own
Duration PT1H30M, P2D or 1h 30m A length of time

A T or a single space can separate the date and the time.

Usage notes

  • Text for people, attribute for machines. Write the content in whatever style suits your readers and language; keep datetime in the strict format.
  • Only real dates and times. Don't wrap vague phrases like "soon" or "a while ago" that have no precise value. For other machine-readable values (prices, product codes) use <data>.
  • Time zones. For events people attend in person, a local time plus the place is often clearest. Add an offset or Z when the exact global moment matters.
  • Accessibility. Screen readers read the visible text, not datetime, so the visible text must make sense on its own.
  • Structured data. Blog posts and events often use <time> alongside microdata or JSON-LD so search engines can show dates in results.

Technical summary

Content categories Flow content, phrasing content, palpable content
Permitted content With datetime: phrasing content. Without it: text only, which must be a valid date, time or duration string
Tag omission None; both the start and end tags are required
Permitted parents Any element that accepts phrasing content
Implicit ARIA role time
DOM interface HTMLTimeElement
Default display inline

Browser support

Supported in every current browser; browsers do not change how it looks, so its value is used by scripts, search engines and extensions.