The <time> element represents a specific period in time: a clock time, a Gregorian date (optionally with time and timezone), or a duration.
Use the datetime attribute for a machine-readable value while showing friendly text to readers. That helps search tools, scripts, and features such as “add to calendar.” For other machine values that are not dates, prefer <data>.
Baseline · Widely available.
Not deprecated. Stable across browsers since about October 2017.
Pre-Gregorian dates.
Do not use <time> for dates before the Gregorian calendar — those values are not reliable in this element.
Note.
If you omit datetime, the element must contain only text (no nested elements), and that text must itself be a valid datetime string.
Syntax
HTML Syntax
syntax.html
<time datetime="value">readable text</time>
Both start and end tags are required. Content is phrasing content when datetime is present. Common datetime shapes: YYYY-MM-DD, HH:MM, YYYY-MM-DDTHH:MM, PT2H30M.
Reference
Attributes
Element-specific attributes on <time> (plus global attributes):
Use T before time parts such as hours and minutes.
Write 2H30M for two hours and thirty minutes → PT2H30M.
Show a short label like 2h 30m as the element text.
Edge Cases & Pitfalls
Most time mistakes are invalid datetime strings or using the element for non-temporal values.
format
Use a valid microsyntax
Values like 07/07/2018 or July 7 are fine as visible text, but not as datetime. Prefer 2018-07-07.
empty
No nested elements without datetime
If datetime is missing, the element may only contain text that is itself a valid datetime value.
history
Skip pre-Gregorian dates
Ancient or Julian-calendar dates are outside what <time> is meant to encode reliably.
semantics
Not every number is a time
Product codes, scores, and other machine values belong in <data>, not <time>.
Compatibility
Browser Support
The <time> element is core HTML phrasing content in modern browsers. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<time>
Widely available since about October 2017. Chrome, Firefox, Safari, Edge, and Opera all support the element and the datetime attribute.
96%Global support (approx.)
Google Chrome62+
Full support
Mozilla Firefox22+
Full support
Apple Safari7+
Full support
Microsoft Edge14+
Full support
Opera49+
Full support
Samsung Internet8+
Full support
Internet Explorer—
No support
<time>Widely supported
Bottom line: Safe for modern sites. Always pair friendly text with a valid datetime when the visible label is not already machine-readable.
Remember
Key Takeaways
Role:<time> marks a date, clock time, or duration.
datetime: put the precise value in the attribute; keep readable text for people.
Formats:YYYY-MM-DD, HH:MM, …T…, PTnHnM, and related microsyntaxes.
Limits: not for pre-Gregorian history; not for non-time machine values.
One line: wrap the date phrase in <time> and set a valid datetime for machines.
UA style
Default CSS Settings
Typical user-agent styling for time (usually unstyled beyond inline flow):
default.css
time {
display: inline;
}
Add your own CSS (weight, color, underline) if you want dates to stand out visually.
Frequently Asked Questions
The time element marks a specific date, time of day, or duration. With a datetime attribute, machines get a precise value while humans still see friendly text.
Strongly recommended when the visible text is not already a valid machine format. If you omit datetime, the element's text content must itself be a valid datetime value and must not contain other elements.
Common ones include YYYY-MM-DD, HH:MM, YYYY-MM-DDTHH:MM with optional timezone, week strings like 2013-W46, and durations such as PT2H30M.
No. Avoid time for dates before the Gregorian calendar because conversion and meaning are unreliable for that period.
Browsers do not restyle it much by default. The value is semantic — useful for search, scripts, and calendar features you build.
No. It is Baseline and widely available across modern browsers.