To make an image clickable, place its <img> element inside an <a> element. Set the anchor’s href to the image file or other destination. To ask the browser to download the file instead of opening it, add the download attribute to the anchor.
<a href="/images/photo.jpg" download="photo.jpg">
<img src="/images/photo.jpg" alt="Download the photo">
</a>
The image’s src controls what appears on the page; the anchor’s href controls what happens when someone activates it. Those URLs can point to the same file or to different files.
Choose whether the image should open or download
An image inside an anchor is a link. Without download, activating it navigates to the anchor’s href. If that URL is an image file, the browser may display the image. Add download when your intent is to request that the linked resource be saved instead.
Open the original image
<a href="photo.jpg">
<img src="photo.jpg" alt="View the full-size photo">
</a>
Here, both URLs refer to the same file: the browser displays it in the page, and the link opens that file. If the displayed image is a smaller preview, point src at the preview and href at the full-size image.
#1 Best Overall
Request a download
<a href="photo.jpg" download="holiday-photo.jpg">
<img src="photo.jpg" alt="Download the holiday photo">
</a>
The download attribute asks the browser to download the linked resource. Its value, here holiday-photo.jpg, suggests the filename. If you omit the value, the browser may derive a name from the response header, URL path, or media type.
Build the link and image markup
-
Choose the file or destination users should reach. Put its URL in the anchor’s
href. -
Choose the image to show on the page. Put its URL in the image’s
src. Use the same URL ashrefif clicking should open or download that displayed image; use a different one if the image is a thumbnail for another file. -
Put the
<img>element between the anchor’s opening and closing tags.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Add useful
alttext describing the link’s destination or action. A linked image’s alternative text functions as the link’s accessible name.Rank #2
SaleHTML and CSS: Design and Build Websites- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
-
Add the
downloadattribute if you want to request a download. Supply a filename only if you have a preferred suggestion.
For example, this thumbnail links to a separate downloadable file:
<a href="/downloads/report-cover.pdf" download="annual-report.pdf">
<img src="/images/report-cover-small.jpg" alt="Download the annual report PDF">
</a>
Although the linked resource is a PDF, the visible thumbnail is a JPEG. A link is not required to point to the same kind of resource as its image.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Understand when the download request works
Same-origin, blob, and data URLs
MDN documents the download attribute for same-origin URLs and for blob: and data: URLs. For a file hosted on the same origin as your page, the attribute is a straightforward way to request a download:
<a href="/images/photo.jpg" download="photo.jpg">
<img src="/images/preview.jpg" alt="Download the photo">
</a>
“Same origin” means the page and resource share the relevant origin, including scheme, host, and port. Do not assume that adding download makes every third-party image URL download; cross-origin behavior has additional restrictions.
Rank #3
Cross-origin files and the server response
For a cross-origin resource, the HTML Standard says a download must be combined with a server response that uses Content-Disposition: attachment to avoid a warning. In practice, if you control the server hosting the file, configure its response to mark the resource as an attachment. A filename parameter in that response can take precedence over the filename suggested by the HTML attribute.
If you do not control the remote server, the most reliable option is to link to a file you host yourself or ask the remote host to provide an attachment response. The download attribute alone is not a way to override another site’s response policy.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesBrowser and user settings
A download request does not guarantee a particular save dialog or a silent save. MDN notes that behavior can vary with the browser and the user’s settings: the resource may prompt, save automatically, or open in the browser or an external application. Design the link so its purpose is clear, but do not promise a specific browser interaction.
Write accessible linked-image text
Use the image’s alt attribute to communicate what activating the link will do or where it leads. For instance, “Download the holiday photo” makes the action clear; “View the full-size photo” describes a link that opens the original.
Avoid relying on a filename, visual appearance, or surrounding layout to explain the link. Someone using a screen reader may encounter the link through its accessible name without seeing the image. If the image is only decoration and adjacent link text already names the destination, avoid making the image’s alternative text repeat that wording; the link should still have a clear accessible name.
Rank #4
Troubleshoot image links that do not download
The click opens the image instead
-
Check that
downloadis on the<a>element, not on<img>. -
Confirm that the anchor’s
hrefpoints to the file you mean to save. The image’ssrconly selects the displayed image.Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
If the resource is cross-origin, check whether its server sends
Content-Disposition: attachment. The HTML Standard describes this server header as necessary in cross-origin cases to avoid a warning. -
Check the response filename as well as the attribute value. A server-provided filename can override the suggested filename.
The wrong file or filename is used
-
Compare the exact
hrefandsrcvalues. A thumbnail insrcand a full-size file inhrefis valid, but they are intentionally different resources. -
Check whether
downloadhas a value. If it does, that value is a suggested name, not an unconditional override of server behavior.Recommended: Fix Windows Errors and Clear Junk Files in Minutes - Free Scan →Recommended: Crashes or Glitches? A Free Driver Scan Usually Finds the Culprit →Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Best Value
-
When the attribute has no value, the browser may choose a name based on response metadata, the URL path, or the media type.
The link does nothing or shows an error
-
Open the
hrefURL directly to check that it resolves to the intended resource and that the user can access it. -
Check spelling, capitalization, and the path. A relative path such as
photo.jpgresolves relative to the current page;/images/photo.jpgstarts at the site root. -
If the file is remote, confirm that the host permits access and supplies the file response you expect. HTML markup cannot make an unavailable resource accessible.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
The browser saves, opens, or prompts differently than expected
First determine whether the file itself is correct and whether the server response is appropriate. Then test in the browser and settings your audience uses. Download behavior is affected by browser implementation and user preferences; the attribute is a request, not a command to display a particular dialog.
Or skip the browser setup
If your separate goal is to capture a webpage as an image or PDF—not to download an image file linked in your HTML—ScreenshotNeo can return a screenshot with one GET request. Its cleanup can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides screenshot tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. See the ScreenshotNeo documentation for API details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
This captures a screenshot of the rendered webpage; it does not replace the HTML anchor-and-download pattern above. Sign up for 1,000 free screenshots a month, with no card required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools




