Skip to content
AITroveRead. Build. Understand.
Make this comfortable

HTML time and data: pair readable copy with machine-readable values

Last updated: 7 Oct 20266 min read
tutorial
IntermediateBy AITrove Editorial

time can carry a machine-readable date or time, while data can attach a machine-readable value to visible text.

Use it for a real task

The receipt page shows a localized review deadline while keeping an ISO-formatted dateTime attribute for parsers. Its state label also carries a stable code. Neither attribute validates a business rule; the application must still decide when the deadline expires and who can approve.

html
<p>Review by <time datetime="2026-10-23">23 October 2026</time>.</p>
<p>Status: <data value="awaiting-review">Awaiting review</data>.</p>

What the markup guarantees

The visible date must agree with datetime. If the deadline includes a time zone, include the offset in the machine value and explain the local time to the reader; a bare calendar date is not a universal instant.

Cost and limits

These attributes cost almost nothing to render. Their maintenance cost is synchronization: changing the visible copy without updating the machine value creates conflicting facts.

Common Mistakes

  • Do not put an incompatible date in datetime.
  • A state code in data is metadata, not an authorization check.
  • Do not treat a local date as an exact instant without a time zone.

Connected lessons

Related: HTML data element: pair visible labels with machine values.

Related: HTML ins and del: show an edit without falsifying current text.

html
semantics
Storage details