HTML Basics

HTML Introduction HTML Basic HTML Comments HTML Tags/Elements HTML Attributes HTML Formatting HTML Block and Inline HTML Charsets HTML Classes HTML Colors HTML Div HTML Headings HTML Id HTML Iframes HTML Images HTML File Paths HTML Tables HTML Layout HTML Lists HTML Links <a> HTML Paragraphs HTML Quotations HTML JavaScript HTML Emojis HTML URL Encode HTML Entities HTML Computercode HTML Symbols HTML Styles

HTML Forms

HTML Forms HTML Form Elements HTML Form Attributes HTML Input Attributes HTML Input Regex HTML Input Form Attributes HTML Input Types

HTML SEO

HTML Head HTML Page Title HTML Responsive HTML Semantics HTML Favicon

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Audio HTML Video

HTML Reference

a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl DOCTYPE dt em embed fieldset figcaption figure font footer form frame frameset h1_-_h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr

HTML <time> Tag

The <time> tag in HTML is used to represent a specific time or duration. It can be used to mark up dates, times, or durations in a machine-readable format.

How to Use the <time> Tag

To use the <time> tag, simply wrap the date, time, or duration in the tag like this:

<time datetime="2022-05-15T09:30:00-04:00">May 15, 2022 9:30 AM</time>

In this example, the datetime attribute is used to provide the machine-readable date and time in the format of YYYY-MM-DDTHH:MM:SS-ZZ:ZZ. The content of the tag is what will be displayed to users on the page.

Main Attributes of the <time> Tag

Attribute Description
datetime Specifies the date and/or time in a machine-readable format
pubdate Specifies that the date and time are the publication date of the content

Examples of Using the <time> Tag

Here are some examples of how you can use the <time> tag:

<p>The event starts at <time datetime="2022-06-20T16:00:00-04:00">4:00 PM</time></p>

<article>
  <h2>Article Title</h2>
  <p>Published on <time datetime="2022-04-10" pubdate>April 10, 2022</time></p>
</article>

By using the <time> tag, you can provide additional context about dates and times within your HTML code.