Interactive online courses HTML Academy
2026-03-09 12:25 Diff

In the next blogpost, Muffin wants to clarify the exact time of the day (or rather the night) that the post was written. A string with the time can be simply left in the text, but there is a better option. HTML has a special tag for marking up the date and time. This is the <time> tag.

You can use the <time> tag to describe the dates in two formats at the same time, one that is human-friendly and one that is machine-readable.

The human-friendly time can be in any format: “Yesterday”, “Saturday”, “суббота”, “The Feast of Saint Muffin” are all legitimate. But machines don’t understand such ambiguous descriptions, so they require a strict format called the ISO 8601 format.

The date for the person is described inside the tag, and the machine-friendly date is described inside the datetimeattribute:

<time datetime="2016-11-18T09:54">09:54 AM</time> <time datetime="2015-11-18">November 18, 2015</time> <time datetime="2018-09-23">last Saturday</time> <time datetime="2017-04-20">yesterday</time>

The browser will only display the contents of the tag; the contents of datetime will not be displayed. A person will see only the indication of the time that is clear them, and the machine will read the attribute and obtain the date in the unambiguous format it needs. So everyone will be satisfied, which is nice.

We added some styles to make the <time> tags look prettier. You can explore the styles in the style.css tab.