HTML5: How to specify the date and time when the text was inserted/changed?
Solution:
HTML Code:
<!DOCTYPE html><!-- Declares the document type and version of HTML -->
<html>
<head>
<meta charset="utf-8"><!-- Specifies the character encoding for the document -->
<title>How to specify the date and time when the text was inserted/changed </title><!-- Sets the title of the document -->
</head>
<body>
<p> The elements and attributes those usage have been changed in HTML5 <!-- Starts a paragraph -->
<ins datetime="2014-02-20T10:30:03Z"><!-- Represents inserted text with a datetime attribute to specify the date and time when the text was inserted or changed -->
(in comparison with HTML4.01)...</ins></p><!-- The inserted text -->
</body>
</html>
Explanation:
- The HTML document starts with a declaration of its type and version (<!DOCTYPE html>).
- The <html> element encloses the entire HTML document.
- The <head> section contains metadata about the document, including the character encoding (<meta charset="utf-8">) and the title of the document (<title>).
- Inside the <body> section, there's a <p> element, which represents a paragraph of text.
- Within the paragraph, there's an <ins> element, which indicates inserted text. The datetime attribute specifies the date and time when the text was inserted or changed. In this case, the datetime attribute is set to "2014-02-20T10:30:03Z" to indicate February 20, 2014, at 10:30:03 AM UTC.
- The text "(in comparison with HTML4.01)..." is marked as inserted text and displayed in the paragraph.
Live Demo:
See the Pen insert-datetime-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/html-css-exercise/basic/insert-datetime-answer.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics