HTML DOM del cite Property


The HTML DOM del cite property associated with the HTML <del> element is used for telling the user why some text on the website was deleted. It does so by specifying the url which states why the given text was deleted.

The del cite property increases the accessibility of our website as it has no visual cues but can help the screen readers. The del cite property sets or returns the value of the cite attribute of the HTML <del> element.

Syntax

Following is the syntax for −

Setting the cite property −

delObject.cite = URL

Here, URL specifies the URL of the document that states why the text was deleted. The URL can be relative or absolute.

Example

Let us look at an example for the HTML DOM del cite property −

Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Del cite</title>
<style>
#Sample{color:blue};
</style>
</head>
<body>
<h2>del cite property example</h2>
<p><del id="Del1" cite="sampleDeleted.html">Some text has been deleted</del></p>
<p>Click the below button to change the cite attribute value of the above deleted text</p>
<button onclick="citeChange()">Change Cite</button>
<p id="Sample"></p>
<script>
   function citeChange() {
      document.getElementById("Del1").cite = "https://example.com/deletedText.html";
      document.getElementById("Sample").innerHTML = "The del cite attribute value was changed to 'https://example.com/deletedText.html'.";
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking the Change Cite button −

In the above example −

We have first created <del> element inside a <p> element that has the id “Del1” associated with it and the cite attribute value for the del element is set to “sampleDeleted.html”.

<p><del id="Del1" cite="sampleDeleted.html">Some text has been deleted</del></p>

We have then created a “Change Cite” button that will execute the citeChange() method when clicked by the user −

<button onclick="citeChange()">Change Cite</button>

The citeChange() method gets the <del> element using the getElementById() method and changes its cite property value to “https://example.com/deletedText.html” . We then display this change in the paragraph with id “Sample” using the innerHTML property of the paragraph element. The text inside the “Sample” paragraph is displayed in blue because we have the style corresponding to its id applied to it −

function citeChange() {
   document.getElementById("Del1").cite = "https://example.com/deletedText.html";
   document.getElementById("Sample").innerHTML = "The del cite attribute value was changed to 'https://example.com/deletedText.html'.";
}

Updated on: 15-Feb-2021

69 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements