html tutorial - datetime Attribute in HTML - html5 - html code - html form



Datetime attribute in html

Learn html - html tutorial - datetime Attribute in HTML - html examples - html programs

  • The datetime attribute specifies the date and time when the text was deleted or inserted.
  • The datetime attribute when used together with the <time> tag, it represents a date and or time of the <time> tag.
  • The datetime attribute has no visual effect in ordinary web browsers, but can be used by screen readers.

Syntax for datetime attribute in HTML:

<element datetime= “YYYY-MM-DDThh:mm:ssTZD”</element>

Differences between HTML 4.01 and HTML5 for datetime attribute:

HTML 4.01

  • HTML4 does not support <time> element

HTML 5

  • HTML5 support <time> element.

Applies To:

Elements Attribute
<del> datetime
<ins> datetime
<time> datetime

Attribute Values:

Value Description
YYYY-MM-DDThh:mm:ssTZD
  • It is specifying the date or time.
  • YYYY is denotes year.
  • DD is denoting the date.
  • T is denotes a space.
  • hh denotes an hour.
  • mm denotes a minute.
  • ss denotes a second.
  • TZD denotes Time Zone Designator.
  • Sample Coding for datetime Attribute in HTML:

    Tryit<!DOCTYPE html>
    <html>
    <body>
             <head>
              <title>Wikitechy datetime attribute</title>
             </head>
                 <p>
                 <del datetime=”2014-7-22T17:55:02Z”>Content has been  deleted 
                 </del>
                 </p>
                 <p><ins datetime=”2014-7-22T17:55:02Z”>
                 Content is here.</ins></p>
                 <p>I have a date on  <time datetime=”2017-05-14 00:01”>
                 Mothers day.</time> </p>
     </body>
     </html>

    Code Explanation for datetime Attribute in HTML:

     datetime Attribute Code Explanation

    1. datetime is used to define the date and time along with the content.

    Output for datetime Attribute in HTML:

     datetime Attribute Tag Output

    1. <del> element is used along with the datetime attribute. As content is shown in output.
    2. <ins> element is used along with the datetime attribute. As content is shown in output.
    3. <time> element is used along with the datetime attribute. As content is shown in output. But datetime attribute has no visual effect in ordinary web browsers, but can be used by screen readers.

    Browser Support for datetime Attribute in HTML:

    Yes Yes Yes Yes Yes

    Related Searches to datetime Attribute in html