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

Wrap the image in an anchor element and put the destination in the anchor’s href. The image’s src still points to the image file:

<a href="https://example.com/">
  <img src="photo.jpg" alt="Visit the example page">
</a>

The anchor makes its contents clickable. For an image-only link, its alt text should tell users what the link does or where it goes—not merely describe what the image looks like.

Make an image clickable with an anchor

Use an <a> element for navigation and place the <img> inside it. Set the anchor’s href to the destination and the image’s src to the image resource:

<a href="https://example.com/">
  <img src="photo.jpg" alt="Visit the example page">
</a>

Here, https://example.com/ is where the link goes; photo.jpg is the file the browser displays. These attributes do different jobs, so do not put the destination in src or the image filename in href. The <a> creates the link; the image is its visible, clickable content. MDN’s image reference documents this pattern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
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

Link to a page or to an image file

The destination can be a web page or a file. For example, to make a thumbnail link to a larger image, use the thumbnail as src and the larger image’s address as href:

<a href="large-photo.jpg">
  <img src="thumbnail.jpg" alt="View the full-size landscape photo">
</a>

Use a destination that matches the link’s purpose. If the image instead triggers an in-page action, such as opening a panel, use a button rather than an anchor pointing to # or javascript:void(0).

Write alt text that explains the link

When the image is the only content inside the link, the image’s alternative text supplies the link’s accessible name. Write it to convey the destination or action. “Visit the example page” identifies a purpose; “blue rectangle” describes appearance but may not tell someone using assistive technology where the link leads. W3C WAI and MDN both emphasize meaningful text for image links.

Image-only link

<a href="https://example.com/">
  <img src="example-logo.png" alt="Visit Example.com">
</a>

Choose wording that accurately describes the destination or action in your page’s context. An alt value such as “Visit Example.com” is appropriate only if that is what activating the link does.

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

Image alongside visible link text

If visible text already names the destination and the image adds no information, use an empty alt value. This prevents the image from redundantly repeating the link’s purpose:

<a href="https://www.w3.org/">
  <img src="w3c.png" alt="">
  W3C Home
</a>

The link still has a clear name: “W3C Home.” The empty value is intentional; it is not the same as omitting the alt attribute. If the image does add information not conveyed by the text, decide whether that information belongs in the link’s accessible content rather than treating the image as decorative.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Decide whether the link should open in a new tab

Links normally open in the current browsing context. Add target="_blank" only when opening a new tab or window is intentional, and tell users about that behavior in the link’s accessible content or nearby text. MDN notes that browsers usually open _blank in a new tab, but browser settings can affect whether it is a tab or window.

<a href="https://example.com/" target="_blank">
  <img src="photo.jpg" alt="Visit the example page (opens in a new tab)">
</a>

Modern browsers implicitly provide the protection associated with rel="noopener" for target="_blank", according to MDN. Older guidance may still recommend adding it explicitly. The important user-facing point here is to disclose the new-tab behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the markup and fix common problems

  • The image appears but is not clickable: Check that the <img> is nested between the opening and closing <a> tags, and that the anchor has an href.
  • The click opens the wrong thing: Inspect href for the destination and src for the image file. They are separate URLs with separate purposes.
  • The link has no useful accessible name: For an image-only link, replace missing or unhelpful alternative text with text that describes its destination or action.
  • The link text is repeated by a logo or icon: If visible text already names the link and the image is redundant, set that image’s alt to an empty string: alt="".
  • The anchor has no destination-identifying content: Avoid an empty anchor or generic wording such as “click here.” Make the link’s purpose clear in the accessible content.
  • A click is meant to perform an action, not navigate: Use a <button> for an in-page action instead of a fake link such as href="#" or javascript:void(0).
  • A new tab or downloadable file may surprise users: Indicate that behavior in the link’s accessible content or nearby text.

As a final markup check, confirm that the opening and closing anchor tags surround the intended image and that the image has an alt attribute appropriate to the link context. The HTML Living Standard also states that when a link contains only images, their alternative text together must convey the link’s purpose.

Or skip the browser setup

ScreenshotNeo does not create an HTML hyperlink; the anchor markup above does that. If you want an API to capture a screenshot of a page after you add the link, ScreenshotNeo offers a one-request option. Its documented API accepts a URL and returns an image or PDF. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups and chat widgets before capture, with each step able to be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits cost nothing; response headers identify the page verdict and whether it was billed. An MCP server provides take_screenshot, get_page_info and capture_pdf 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. These capture features are separate from writing or checking the HTML link itself.

Sign up for 1,000 free screenshots a month, with no card required.

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.

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.