time: The Time element
The <time>
HTML element represents a specific period in time. It may include the datetime
attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders.
Attributes
Specific attributes
Recommended attributes
datetime="[machine-readable datetime]"
gives the machine-readable equivalent of the element’s contents. The value must be a valid date string with an optional time component.
Global attributes
accesskey
Specifies a keyboard shortcut to activate or focus an element.
aria-*
Defines accessibility properties and states for assistive technologies.
class
Specifies one or more CSS class names for styling the element.
data-*
Stores custom data private to the page or application.
dir
Sets the text direction (left-to-right, right-to-left, or auto).
hidden
Hides the element from display and assistive technologies.
id
Defines a unique identifier for the element within the document.
inputmode
Hints which virtual keyboard type to display on mobile devices.
itemid
Provides a global identifier for microdata items.
itemprop
Defines a property name-value pair for microdata.
itemref
Associates properties with an item via element IDs for microdata.
itemscope
Creates a new microdata item container.
itemtype
Specifies the vocabulary URL for microdata items (like Schema.org).
lang
Specifies the primary language of the element’s content.
nonce
Provides a cryptographic nonce for Content Security Policy.
role
Defines the element’s semantic role for accessibility.
tabindex
Controls keyboard navigation order and focusability.
title
Provides advisory information displayed as a tooltip.
Example
<p>I published my first blog post on <time datetime="2023-05-15">May 15, 2023</time>.</p>
<p>The next Homebrew Website Club meeting is scheduled for <time datetime="2024-03-20T18:30">March 20th at 6:30 PM</time>.</p>
<p>IndieWebCamp Berlin took place <time datetime="2023-11-04">last November</time>, bringing together independent web creators from across Europe.</p>
<p>I've been maintaining my personal website for <time datetime="P2Y6M">two and a half years</time> now.</p>
<article>
<h2>Building Sustainable Web Communities</h2>
<p>Published on <time datetime="2024-01-15T10:00:00Z">January 15, 2024</time></p>
<p>The web works best when it's decentralized and community-driven...</p>
</article>