Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
accessibility

How to Save an Image with a Link in HTML

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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

  1. Choose the file or destination users should reach. Put its URL in the anchor’s href.

  2. Choose the image to show on the page. Put its URL in the image’s src. Use the same URL as href if clicking should open or download that displayed image; use a different one if the image is a thumbnail for another file.

  3. 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.
  4. Add useful alt text describing the link’s destination or action. A linked image’s alternative text functions as the link’s accessible name.

    Rank #2
    Sale
    HTML and CSS: Design and Build Websites
    • HTML CSS Design and Build Web Sites
    • Comes with secure packaging
    • It can be a gift option
  5. Add the download attribute 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand 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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Browser 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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot image links that do not download

The click opens the image instead

The wrong file or filename is used

The link does nothing or shows an error

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.