What it means to turn an image into a link

Turning an image into a link means wrapping an image file with code so that clicking on it takes you somewhere — to another webpage, a document, an email address, or a file download. The image itself stays visible on the page, but it becomes clickable like any text link would be.

This is different from linking to an image file itself (where clicking shows just the image). Instead, you're using the image as the clickable button that triggers an action. A logo that takes you to a homepage, a thumbnail that opens a full-size photo, or a button graphic that downloads a PDF all work this way.

Key Takeaways

  • The simplest method in most website builders is to select the image, then add a link URL in the link field — no code required.
  • In HTML, you nest an image tag inside a link tag: <a href="destination"><img src="image.jpg"></a>
  • The image file and the destination can be anything: another page on your site, an external website, an email address, or a downloadable file.
  • Make sure the image file actually exists in the folder where your webpage is stored, or the image won't display.
  • Test the link by clicking the image in your browser to confirm it goes where you intended.

Using a website builder or editor

If you use WordPress, Wix, Squarespace, Google Sites, or similar platforms, the process is almost always the same. Insert or upload your image, then look for a link icon or "add link" button while the image is selected. Click it and paste or type the destination URL into the field that appears.

In WordPress, select the image in the editor, and a toolbar appears above it. Click the link icon (it looks like a chain), then type or paste the URL you want the image to link to. You can also choose whether the link opens in the same tab or a new one. Click "Apply" and you're done.

In Wix and Squarespace, right-click the image or look for a settings panel on the right side of the editor. Find the "Link" or "Add Link" option, enter your destination, and save. These platforms handle the code for you behind the scenes.

Writing the code yourself in HTML

If you're editing HTML directly or building a webpage from scratch, you wrap the image tag inside a link tag. The structure looks like this:

<a href="https://example.com"><img src="image.jpg" alt="Description of image"></a>

The href attribute in the <a> tag is where the image links to. The src attribute in the <img> tag points to your image file. The alt text describes the image for people using screen readers and appears if the image fails to load.

If your image file is in the same folder as your HTML file, you can use just the filename: src="photo.jpg". If it's in a subfolder called "images", use src="images/photo.jpg". If the image is hosted elsewhere online, use the full URL: src="https://example.com/photo.jpg".

Where the image and link destination can point

The destination URL in the href attribute can be almost anything. Common options include another page on your own website (href="about.html"), an external website (href="https://example.com"), an email address (href="mailto:name@example.com"), or a file to download (href="document.pdf").

You can also link to a specific section of a page using an anchor. If a page has a heading with id="contact", you can link directly to it with href="page.html#contact". This is useful when you want an image to jump to a particular part of a longer page.

Making sure your image actually displays

The most common problem is that the image doesn't show up, even though the link works. This usually means the image file path is wrong. Double-check that the filename matches exactly — photo.jpg is different from Photo.jpg on most computers. Verify the file is actually in the folder you specified.

If you're testing locally on your computer, make sure the image file is in the same folder as your HTML file, or in a subfolder you've correctly referenced. If you're uploading to a web server, upload the image file to the same location as your HTML file, or adjust the path accordingly.

Open your webpage in a browser and look for a broken image icon (usually a small square with an X or a mountain symbol). If you see that, the path is wrong. Right-click the broken image and select "Inspect" or "Inspect Element" to see what path the browser is actually looking for.

Testing your image link

After you've created the link, click the image in your browser to make sure it goes where you intended. If it's a link to another page on your site, that page should load. If it's an external link, you should be taken to that website. If it's a file download, the file should begin downloading.

If the link doesn't work, check the URL in the href attribute. Make sure there are no typos, that the protocol is included (http:// or https://), and that the page or file actually exists. Test the URL by pasting it directly into your browser's address bar to confirm it works on its own.

Frequently Asked Questions

Can I make an image link to a file on my computer instead of a website?

Yes, but only if the file is in the same folder structure as your webpage. Use a relative path like href="downloads/document.pdf". If you're viewing the page locally on your computer, you can link to any file, but once you upload to a web server, only files you've also uploaded will be accessible.

What's the difference between linking an image and linking text?

There's no difference in how the code works — both use the <a> tag. The only difference is what's inside it. Text links have text between the opening and closing tags; image links have an <img> tag instead. The destination and behavior are identical.

Can I add styling or borders to an image that's a link?

Yes. You can use CSS to style the image or the link. By default, linked images often get a blue border in some browsers. You can remove it with style="border: none;" on the image tag, or add your own styling like style="border: 2px solid red;" to create a custom border.

How do I make the link open in a new tab instead of the same one?

Add target="_blank" to the link tag: <a href="https://example.com" target="_blank"><img src="image.jpg"></a>. This tells the browser to open the destination in a new tab or window, leaving your current page open.