Learn HTML – Part 62 – time Tag – Date & Time
The HTML time tag is used to represent dates and times in a machine-readable format.
It helps browsers and search engines understand date and time information correctly.
What is the time Tag?
The time element represents a specific period, date, or time.
It can include a datetime attribute for machine-readable values.
Basic Syntax
<time datetime="2026-03-20">March 20, 2026</time>
Example – Date Representation
<p>
Published on <time datetime="2026-03-20">March 20, 2026</time>
</p>
Output:
Published on
Example – Time Representation
<p>
Event starts at <time datetime="18:00">6:00 PM</time>
</p>
Output:
Event starts at
Example – Date and Time
<time datetime="2026-03-20T18:00">
March 20, 2026 at 6:00 PM
</time>
Output:
Why Use time?
- Provides machine-readable dates
- Improves SEO and search engine understanding
- Enhances accessibility
- Useful for events, blogs, and schedules
The
timetag represents dates and times in a structured format.
Common Mistakes Beginners Make
- Not using the datetime attribute
- Using incorrect date formats
- Confusing display text with machine-readable value
Conclusion
The HTML time tag is used to represent dates and times in a structured way.
It helps both users and machines understand time-related information clearly.
What’s Next?
Now that you have learned most HTML elements, the final step is building a complete HTML project using everything you’ve learned.
Next: Learn HTML – Part 63 – Complete HTML Project →
Series: Learn HTML Series
