<time>

By raae for Semantic Advent |

Short and sweet today, <time> can be used for durations, times, and dates.

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.
MDN Docs

I like how there is no need for super precision, "2023-12" is as valid as "2023-12-07 14:54:39.929Z". Check out the MDN Docs for all valid datetime values.

It's typically used to indicate the publishing date for an article, but can also be used for durations as mentioned above.

<p>
    Semantic Advent post for <time datetime="2023-12-07">December 7th</time>, 
    estimated reading time <time datetime="PT22S">22 seconds</time>.
</p>

And remember! Do not <time> use for dates before the introduction of the Gregorian calendar 😆

Sign up and receive byte-sized emails about Semantic HTML Elements this advent with real-world use cases!