HTML DOM blockquote cite Property


The HTML DOM blockquote cite property is associated with the HTML <blockquote> element. This property is used to set or return the cite attribute of the quote. The cite property is useful for screen readers and not so much for normal user as it doesn’t have any visual effect on the web page. The cite property is used to set the source url of the quote.

Syntax

Following is the syntax for −

Setting the cite property −

blockquoteObject.cite = URL

Here, URL specifies the quotation location.

Example

Let us see an example for the blockquote cite property −

<!DOCTYPE html>
<html>
<body>
<h2>Quote</h2>
<p>Here is a quote:</p>
<blockquote id="myBlockquote" cite="www.webexample.com">
Here is some sample text in place of quote.
</blockquote>
<p>Click the button below to change the above quote cite value.</p>
<button onclick="citeChange()">CHANGE</button>
<p id="Sample"></p>
<script>
   function citeChange() {
      document.getElementById("myBlockquote").cite = "http://www.examplesite.com";
      document.getElementById("Sample").innerHTML = "The value of the cite attribute was
      changed to 'www.examplesite.com' ";
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking CHANGE −

In the above example −

We have taken a <blockquote> element with id “myBlockquote” and the cite property value is webexample −

<blockquote id="myBlockquote" cite="www.webexample.com">
Here is some sample text in place of quote.
</blockquote>

We then have a button CHANGE to execute citeChange() function −

<button onclick="citeChange()">CHANGE</button>

The citeChange() function gets the element which has “myBlockquote” id and gets its cite attribute and changes it to the “www.examplesite.com” . After changing the cite value the message “The value of the cite attribute was changed to 'www.examplesite.com' ” is displayed in the paragraph with id “Sample” associated with it.

function citeChange() {
   document.getElementById("myBlockquote").cite = "http://www.examplesite.com";
   document.getElementById("Sample").innerHTML = "The value of the cite attribute was changed to 'www.examplesite.com' ";
}

Updated on: 06-Aug-2019

71 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements