HTML DOM Anchor download Property

The HTML DOM download property is used to set or return the value of the download attribute of a link.

Following is the syntax to set the download property − = file

Above, file represents the file name you can set for the file to be downloaded. The actual extension will get suffixed.

Following is the syntax to return the download property:

Let us now see an example to implement the DOM Anchor download property −


 Live Demo

<!DOCTYPE html>
<a id="myid" href="" download="Learn
<img src="" alt="ReactJS" width="200"
<button onclick="display()">Display the value</button>
<p id="demo"></p>
   function display() {
      var val = document.getElementById("myid").download;
   document.getElementById("demo").innerHTML = val;


Now, click on the button to display the value −