References

Beginner-friendly references for web development, with live, editable examples.

The HTML datetime attribute

Attribute All modern browsers Updated
Quick answer

The HTML datetime attribute provides a machine-readable date or time. It is used on the <time>, <ins> and <del> elements.

Overview

The datetime attribute provides a machine-readable date or time. It applies to the <time>, <ins> and <del> elements.

It lets machines (and search engines) understand a human-friendly date, and is the basis for rich results like event dates.

Syntax

<time datetime="2026-06-22">June 22, 2026</time>

Values

Value
A valid date/time string, e.g. 2026-06-22, 14:30 or 2026-06-22T14:30.

Best practices

  • Use datetime in valid ISO-8601 format for reliable machine reading.
  • Put a quotation's or edit's source URL in the cite attribute (it is not displayed).
  • For a visible citation, use the <cite> element rather than the attribute.
  • Pair <del> and <ins> to show edits clearly.

Frequently asked questions

What does the datetime attribute do?
Gives a machine-readable date/time.
Is the cite attribute displayed on the page?
No. The cite attribute is machine-readable metadata. For a visible citation, use the <cite> element.
What format does the datetime attribute use?
ISO-8601 — for example 2026-06-22 for a date or 14:30 for a time.
Which elements use the datetime attribute?
It is an element-specific attribute, used on quotation and edit elements like <blockquote>, <q>, <del>, <ins> and <time>.