HTML: <time> tag
This HTML tutorial explains how to use the HTML element called the <time> tag with syntax and examples.
Description
The HTML <time> tag is an HTML5 element that defines either a time value (on a 24-hour clock) or a date (in the Gregorian calendar) in the HTML document. This tag is also commonly referred to as the <time> element.
Syntax
In HTML, the syntax for the <time> tag is:
<body>
<time>Date and time goes here</time>
</body>
Attributes
In addition to the Global Attributes, the following is a list of attributes that are specific to the <time> tag:
Note
- The HTML <time> element is found within the <body> tag.
- The <time> tag should not be used is the date can be calculated.
- The <time> tag should not be used for dates prior to the Gregorian calendar.
- For IE browsers older than IE 9, use HTML5shiv which is a javascript workaround to provide support for the new HTML5 elements such as: <header>, <main>, <article>, <section>, <aside>, <nav>, <footer>.
Example
We will discuss the <time> tag below, exploring examples of how to use the <time> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.
Advertisements