ReferenceStandard

Machine-readable values: data and time

Data associates visible text with a machine-readable value.

Intermediate3 min readLearn · Practice · Review

Published by HTML Code Runner · AI-assisted material · Independent editorial review pending · Editorial policy

On this page

Purpose and content model

Data associates visible text with a machine-readable value. Time does the same for dates, times, durations, and related temporal values. These elements let the interface use friendly wording while keeping an unambiguous value in the markup. They do not automatically create a database, calendar reminder, or localized display.

Both contain phrasing content. Use time when the value fits one of its supported temporal formats; use data for other identifiers or values. Choosing the right element makes the representation easier for a future script or consuming system to interpret without extracting numbers from prose.

Syntax and working example

<p>The workshop is on <time datetime="2026-11-14">14 November 2026</time>.</p>
<p>It lasts <time datetime="PT90M">an hour and a half</time>.</p>

Supported attributes and behavior

Data requires value. Time uses datetime when its displayed text is not already a valid machine-readable time value. Supported forms include calendar dates, times, date-time combinations, and valid duration forms. A time without a time-zone offset is not automatically an unambiguous global instant. Global lang may describe the visible text's language, but it does not alter datetime syntax.

Another practical pattern

<p>Order item: <data value="BK-204">Introduction to gardening</data></p>
<p>Starts at <time datetime="2026-11-14T10:00:00+05:30">10:00 India time</time>.</p>

Accessibility and browser notes

Keep the visible date understandable to the audience. A machine-readable attribute does not guarantee that assistive technology will announce a more helpful version than the displayed text. Include time-zone information visibly when an event crosses regions, rather than requiring users to inspect source.

Common mistakes

Do not assume 03/04/26 has the same meaning in every locale. Do not put a price with currency symbols into datetime. A data value is not secret merely because it is stored in an attribute; anyone can inspect it.

Verify your implementation

Check the machine value independently of the visible phrase. Verify calendar dates around month and year boundaries and confirm time-zone offsets for the event's actual instant. If a script reads the value, test missing and invalid attributes instead of silently substituting today's date.

Standard status and sources

Standard; browser availability must be checked independently of specification status.

HTML specification · MDN reference and compatibility data