Introduction to HTML time Tag

HTML time Tag

Introduction to HTML time Tag

As we all knew the HTML is ever-evolving in the web development field, and it’s a popular mark-up language around the world. It is said that Web developers need to update and learn about the HTML element. In this article, we are going to learn a few important tags called time tag. The fact that it is easy for the human to read date/time in many forms, but when coming to machines, it is difficult to parse, by then <time> comes in. This <time> tag defines a particular period in time and specifying the date and time for the particular web pages so they are very useful too and represent the human-readable tag. This human-readable is a valuable format of internet protocols. The <time> tag is supported in HTML 5 but not in HTML 4.01 version.

The time can be defined in the following ways:

  • Time duration
  • Correct time on 24 – hour
  • The date on Gregorian Calendar

With the benefits of the time progress, web pages are done more structured and make the HTML code to read easily by the search engines to analyze the idea on the web page and benefits for developing event scheduling and any time- related event functions. For example, In the search engine is connected with current events, it helps in ranking the current web page higher by visual time events.


<time> 2020-01-28 </time>

Using the basic date-time attribute gives the time tag unique with specific formats as it is meant for computers.

From the above syntax, it is said that the <time> tag holds both time, date or even both together. The expected format is given from the largest period to the lower period year – month- date hh: mm: ss time zone. In the absence of the Date Time attribute, this format is used.


Attribute plays an important role in HTML. With this HTML element user has the flexibility to add Schedules date on their work and birthday reminders on their respective calendars another benefit is search engine can give us better search results. This time element supports global and event attributes; apart from that, a very important attribute is Date Time. To display the values like ‘Monday’, ‘Friday’ date-time attribute is represented.

The below table illustrates the attribute and their description related to this element:

Attribute NameDescription
DateTimeIt specifies a machine-readable input time of the element.
PubdateIt has a Boolean value that Specifies the publication date of the content.

There are some different ways of representing the date-time attribute. The standards are given in the profile of ISO 8601. And it is defined using the notation ABNF. And the letters below ‘T’ and ‘Z’ should be declared in the Upper case. Popular Course in this categoryHTML Training (12 Courses, 19+ Projects, 4 Quizzes)12 Online Courses | 19 Hands-on Projects | 89+ Hours | Verifiable Certificate of Completion | Lifetime Access | | 4 Quizzes with Solutions
4.5 (6,492 ratings)Course Price
₹6999 ₹41999
View Course

Related CoursesBootstrap Training (2 Courses, 6+ Projects)XML Training (5 Courses, 6+ Projects)CSS Training (9 Courses, 9+ Projects)

1. Year and Month

Very Simple Format with the year before.

2019 – 08

2. Date Alone


3. Date without Year


4. Only Time Display

13: 55: 30. 522

5. Date and Time

2014 – 08 -21T15:55

Here T is for separation between Date and Time.

6. Time Zone Format

It initiates with either plus or minus and in some cases ( : ) is replaced With capital ‘ Z ’.

+ 08 : 05

7. Year and Week

Here ‘W’ is represented for a week with the respective number of weeks.

2017 – W 20

8. Duration (with Two methods)

2w 3d 4 h 25 min 12.402s

Also, it supports global attribute along with this element like id, class, style and supporting event attributes like onabort, onfocus, onclick, onmousedown, onmouseout, onkeyup, onchange, ondrag, ondrop, onselect, onmessage, onscroll.

Examples to Implement HTML time Tag

This tag can also be used without using datetime Attribute to display either date or time. The following are some examples:

Example #1 – using a <time> tag.


<!DOCTYPE html>
HTML Time Tag
<body style="text-align:left;">
<h2>HTML Time Tag demo</h2>
<p> India celebrate as
<time>2020-01-26</time> Republic day


HTML time Tag 1

Example #2

Making time element to the title attribute to show detailed information of the user in the format with the nice human-readable format or either machine-readable format.


<!DOCTYPE html>
<h2> <center> Date Time Example </center> </h2>
<h3>The Stand- Up Comedy show starts at <time datetime="2018-07-04T20:00:00Z">20:00</time> coming Saturday.</h3>
<h3>The preview show starts in <time datetime="PT3H0M3S">5h 1m 0s</time>.</h3>

In the below Output, the time tag instructs the browser about the text used between the attribute is a time reference ( 5 h 1m 0s) but doesn’t display the time attribute.


HTML time Tag 2

Example #3 – Using Css.


<!doctype html>
<body style="background-color:yellow;">
<h1>Title of the document</h1>
<p>Introduction to the Article</p>
<p>This content is published on <time>2016-1-20</time>.</p>
<p>Our shop opens at <time>08:00</time>.</p>


Title of document

Example #4 – Using pubdate attribute.


<!DOCTYPE html>
<h1>A good Article</h1>
<p>Introduction on a given Article.</p>
<p>Content published on <time datetime="2019-02-04" pubdate>February the 4th, 2019</time>


A good article


Therefore, we had learned how to work with the <time> tag and also, we came to know how the web crawlers interpret the date and time on the web page. People started using the time tag in the HTML document as the usage of this tag increased in the search engines. Using the date/time attribute browser gets clear about what the time is, and some websites make their default time theme like Reddit, word press, etc.

Recommended Articles

This is a guide to HTML time Tag. Here we discuss the introduction, attributes, and different examples of HTML time Tag. You may also have a look at the following articles to learn more –

  1. Types of Tags in HTML
  2. Option Tag in HTML
  3. Font Tag in HTML
  4. HTML Picture Tag

Leave a Comment

Your email address will not be published. Required fields are marked *