Open In App

How to use the download Attribute in HTML5 ?

Last Updated : 31 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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=
            <img src=
                 alt="gfg"
                 width="500"
                 height="200">
        </a>
</body>
 
</html>


Output: 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads