HTML <time> Tag

The <time> tag is one of the HTML5 elements. It is used to define one of the following:

The <time> tag should not be used for dates that are prior to the introduction of the Gregorian calendar.

The datetime attribute is used to define machine-readable format, which allows search engines to produce smarter results and user agents to add reminders to the user’s calendar. When the datetime attribute is missing, the <time> element should not have any element descendants. In this case, the datetime value will be the child text content of the element.


The <time> tag comes in pairs. The content is written between the opening (<time>) and closing (</time>) tags.

Example of the HTML <time> tag:

<!DOCTYPE html>
    <title>Title of the document.</title>
    <p>The game will be held on <time datetime="2018-09-28 19:00">September 28</time>.</p>
    <p>It will start at <time>19:00</time></p>


time example


Attribute Value Description
datetime Indicates the time/date of the element in the following formats:
YYYY - a four-digit year
MM - a two-digit month, 01 - 12
DD - a two-digit day, 01 - 31
T -specifies that a time value follows
hh -a two-digit hour, 00 - 24
mm - a two-digit minute, 00 - 59
ss -a two-digit second, 00 - 59
TZD - (Time Zone Designator) time zone

The <time> tag also supports the Global Attributes.

How to style <time> tag?

Common properties to alter the visual weight/emphasis/size of text in <time> tag:

  • CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit.
  • CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
  • CSS font-size property sets the size of the font.
  • CSS font-weight property defines whether the font should be bold or thick.
  • CSS text-transform property controls text case and capitalization.
  • CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.

Coloring text in <time> tag:

  • CSS color property describes the color of the text content and text decorations.
  • CSS background-color property sets the background color of an element.

Text layout styles for <time> tag:

  • CSS text-indent property specifies the indentation of the first line in a text block.
  • CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user.
  • CSS white-space property specifies how white-space inside an element is handled.
  • CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for <time> tag:

Browser support

chrome firefox safari opera
6+ 4+ 5+ 11.1+

Practice Your Knowledge

What is true about the HTML <time> tag?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?