HTML - attributes - download

revision:


Content

"download" attribute : specifies that target will be downloaded syntax some examples


"download" attribute : specifies that target will be downloaded

top

It specifies that the file specified in the "href" attribute will be downloaded when a user clicks on the hyperlink. The optional value of the download attribute will be the new name of the file after it is downloaded.
There are no restrictions on allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.). If the value is omitted, the original filename is used.

The download attribute can be used on the <a> and <area> elements.


syntax

top

<a download="filename"></a>

filename is optional and specifies the new filename for the downloaded file.


some examples

top

Click on the image to download it:

car
codes:
                    <a href="../pics/car2.jpg" download>
                        <img src="../../pics/car2.jpg" alt="car" width="200" height="142">
                    </a>
                

Click on the image to download it:

holiday
codes:
                    <a href="../pics/1.jpg" download="sweet">
                        <img src="../../pics/1.jpg" alt="holiday" width="200" height="142">
                    </a>