The download attribute in HTML5 is used to prompt the user to download a linked resource rather than navigate to it. When applied to an anchor <a> tag, it signifies that the linked file should be downloaded when the link is clicked.
Syntax
<a href="img/gfg.jpg" download>Link</a>
Usage
- Enables direct file downloads with the `download` attribute.
- Provides user-friendly filenames for downloaded files.
- Useful for offering downloadable documents like PDFs.
- Facilitates the download of media files from web pages.
- Improves accessibility by simplifying resource downloads.
Example:
HTML
<!DOCTYPE html> < html >
< head >
< title >
HTML a download Attribute
</ title >
</ head >
< body >
< p >Click on image to download
< p >
< a href =
"https://media.geeksforgeeks.org/wp-content/uploads/20190221234751/geeksforgeeks-logo1.png" download>
< img src =
alt = "gfg"
width = "500"
height = "200" >
</ a >
</ body >
</ html >
|
Output:
Article Tags :