What is 'time' element in HTML?

HTML uses tags and elements to build a web page. One of these is the time element.

The time element

The time element represents the current time in a human-readable form. The default format is hh:mm:ss.

We can use the datetime attribute within the time tag to display the current time along with the date, month, and year like this: YYYY-MM-DD: hh:mm:ss.

time and date format

Syntax

The time element has an opening tag <time> and a closing tag </time>. We can include attributes such as datetime within the time element tags.

The general syntax to write the time element in a web page is as follows:

<time>05:40:15</time>
<time datetime = "2021-07-23 05:41:23"> </time>

Code

Let’s implement an example code in HTML to learn the usage of the time element.

The 'time' element

Explanation

In the code above, there are different formats of time that display how we can use the time element.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved