Open In App

How to set date and time when the text was deleted using HTML ?

Improve
Improve
Like Article
Like
Save
Share
Report

The <del> tag in HTML stands for delete and is used to mark a portion of text which has been deleted from the document. The deleted text is rendered as strikethrough text by the web browsers although this property can be changed using CSS text-decoration property. The <del> tag requires a starting and ending tag.

The <del> datetime attribute is used to specify the date and time of the deleted text.

Syntax:

<del datetime=""> Contents... </del>

Attribute Values: This attribute contains single value YYYY-MM-DDThh:mm:ssTZD which is used to specify the date and time when the text was deleted.

The explanation of datetime components are listed below:

  • YYYY: It sets the year of datetime object (e.g. 2009).
  • MM: It sets the month of datetime object (e.g. 05 for March).
  • DD: It sets the day of the month of datetime object (e.g. 04).
  • T: It is a required separator.
  • hh: It sets the hour of datetime object (e.g. 18 for 06.00pm).
  • mm: It sets the minutes of datetime object (e.g. 34).
  • ss: It sets the seconds of datetime object (e.g. 40).
  • TZD: Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)

Example:

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        How to specify the date and time
        when the text was deleted?
    </title>
 
    <style>
        del {
            color: red;
        }
 
        ins {
            color: green;
        }
    </style>
</head>
 
<body style="text-align:center">
 
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
 
    <h3>
        How to specify the date and time
        when the text was deleted?
    </h3>
 
     
     
<p>
        GeeksforGeeks is a <del
        datetime="2018-11-21T15:55:03Z">
        mathematical</del> <ins>computer</ins>
        science portal
    </p>
 
 
</body>
 
</html>


Output:

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Last Updated : 09 Jul, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads