The <time> element is used for give a machine-readable date or time. You will run into it while reading other people’s HTML, and it is useful to know what job it does before copying the code.
What does <time> mean?
Give a machine-readable date or time. The tag gives the browser a specific kind of content to work with. It is more helpful to choose a tag for its meaning than because of its default look.
Datetime gives software a consistent value even when visible text is friendly.
A working HTML example
Here is a small example you can place in an HTML page and inspect in your browser:
<section>
<p>The event starts <time datetime="2026-11-12T14:30">November 12 at 2:30 PM</time>.</p>
</section>
Reading the example
Find the <time> part first. Notice which elements are around it and how its content or attributes are connected to those other elements.
In this example, <time> appears alongside datetime attribute. That context is often just as important as the element itself.
The browser builds its document from these relationships. Any CSS changes appearance, while interactive JavaScript behavior must be provided separately when the example includes it.
When should you use it?
Use <time> when you want to give a machine-readable date or time. A sensible example of this on a real website is the markup shown above; it gives the browser and accessibility tools a clearer job to work with.
Common companions are datetime attribute. Check the nesting requirements before moving the element into a different location.
Try it yourself
Change the visible date wording without changing the machine-readable meaning.
Common Beginner Mistakes
- A bare datetime with no time zone does not magically represent a universal instant.
- Picking
<time>only because it looks a certain way instead of checking what it means. - Forgetting to inspect the surrounding markup when an element does not behave as expected.
Key Takeaways
<time>helps give a machine-readable date or time.- Datetime gives software a consistent value even when visible text is friendly.
- Start with meaningful markup, then add styling or scripting only when the page needs it.