The simplest way to make a photo clickable

To make a photo a link, you wrap the image tag in an anchor tag. The anchor tag is what creates the link, and the image tag sits inside it. When someone clicks the photo, they go wherever the link points.

Here is the actual code you need:

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

Replace https://example.com with the URL you want the photo to link to. Replace photo.jpg with the actual filename of your image. The alt text describes the photo for people using screen readers — write something brief that explains what the image shows.

This method works the same way whether you are writing HTML directly, using WordPress, Wix, Squarespace, or most other website builders. The structure never changes: anchor tag on the outside, image tag on the inside.

Key Takeaways

  • Wrap your image tag inside an anchor tag to make the photo clickable.
  • The href attribute in the anchor tag controls where the link goes.
  • Always include alt text that describes what the photo shows.
  • You can style the link with CSS to remove the border that appears around images by default.
  • This method works the same way in HTML, WordPress, Squarespace, and most website builders.

Where to put the code

If you are writing HTML directly, paste the code into your .html file wherever you want the photo to appear. If you are using a website builder like WordPress, Wix, or Squarespace, look for a "code" or "custom HTML" block, paste the code there, and save.

Some builders also let you right-click an image and choose "link" from a menu — that does the same thing without typing code. In WordPress's block editor, click the image, then look for a link icon in the toolbar. In Squarespace, select the image and look for a "link" option in the sidebar. Check your builder's help section if you are not sure where to find it.

Removing the blue border around the photo

By default, browsers put a thin blue or colored border around images that are links. If you do not want that border, add this CSS to your page:

a img { border: none; }

Paste this inside a <style> tag in the head of your HTML document, or add it to your site's CSS file. This removes the border from all images that are links on your page. If you are using a website builder, paste it in the custom CSS section, usually found under site settings or design options.

If you want the border to appear only on hover (when someone moves their mouse over the photo), use this instead:

a img:hover { border: 2px solid blue; }

Making the photo open in a new tab

To make the link open in a new tab instead of replacing the current page, add target="_blank" to the anchor tag:

<a href="https://example.com" target="_blank"><img src="photo.jpg" alt="description"></a>

This is useful when you are linking to another website and want visitors to stay on your page. Be careful not to overuse it — many people find new tabs annoying, and it can make your site feel less in control. Most website builders also have a checkbox for this option if you are using the visual editor instead of code.

Linking to a different image or file

The href can point to anything: another webpage, a PDF, a larger version of the same photo, or a downloadable file. For example, you could make a thumbnail image link to the full-size version:

<a href="large-photo.jpg"><img src="thumbnail.jpg" alt="click to enlarge"></a>

When someone clicks the thumbnail, the browser opens the large photo. This is common on portfolio sites and photo galleries. You can also link to a PDF or a ZIP file the same way — just put the filename or full URL in the href.

Adding a title that appears on hover

You can add a title attribute to the anchor tag to show text when someone hovers over the photo:

<a href="https://example.com" title="Click to visit our homepage"><img src="photo.jpg" alt="description"></a>

The title appears as a small tooltip. Keep it short — one or two words usually works best. Do not repeat the alt text; use the title to tell people what happens when they click. On mobile devices, the title may not appear at all, so do not rely on it to convey important information.

Frequently Asked Questions

Can I make only part of a photo clickable?

Yes, but it requires an image map or a more complex setup with overlays. For most cases, it is easier to use a button or text link next to the photo instead. If you need clickable regions within a single image, search for "HTML image map" or use an interactive image tool.

Does making a photo a link hurt my search engine ranking?

No. Search engines treat image links the same as text links. Make sure your alt text describes the image accurately, and the link goes somewhere relevant. That is all that matters for search engines.

What if the photo and the link destination are on different servers?

It does not matter. You can link to any URL on the internet. The photo can be hosted on your server and the link can point anywhere else, or vice versa. Just make sure the image file path is correct.

How do I make the photo a link in WordPress?

In the WordPress block editor, insert an image block, then click the image and look for a link icon in the toolbar. Click it and paste the URL you want to link to. WordPress handles the code for you. If you are using the classic editor, right-click the image and choose "edit link".

Can I add a caption to a photo that is also a link?

Yes. Wrap both the image and the caption text in the anchor tag, or use a figure and figcaption element inside the link. The exact method depends on your HTML structure, but the photo itself stays inside the anchor tag either way.