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

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 |
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 is used to define the date and time along with the content.
Output for datetime Attribute in HTML:

- <del> element is used along with the datetime attribute. As content is shown in output.
- <ins> element is used along with the datetime attribute. As content is shown in output.
- <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 |