The basic method: wrap your image in an anchor tag
To make a picture clickable, you put the image tag inside an anchor tag. The anchor tag is what creates the link — it tells the browser where to send someone when they click. Here's the structure:
<a href="https://example.com"><img src="image.jpg" alt="description"></a>
The href attribute inside the <a> tag is where you put the URL — the page or file you want the image to link to. The src attribute inside the <img> tag is the path to your image file. The alt attribute describes what the image shows, which matters for accessibility and search engines.
That's the whole thing. When someone clicks the image, they go to the URL in the href. If you want the link to open in a new tab instead of replacing the current page, add target="_blank" to the anchor tag.
Key Takeaways
- Wrap your image tag with an anchor tag: <a href="URL"><img src="image.jpg"></a>
- The href attribute holds the destination URL, and the src attribute holds the path to your image file.
- Always include an alt attribute on the image to describe what it shows.
- Add target="_blank" to the anchor tag if you want the link to open in a new tab.
- Remove the default blue border around the image with CSS if you don't want it to look like a traditional link.
Where to put the image file path
The src attribute needs to point to where your image actually lives. If the image is in the same folder as your HTML file, you just use the filename: <img src="photo.jpg">. If it's in a subfolder called "images", use <img src="images/photo.jpg">.
You can also link to an image hosted on another website by using the full URL: <img src="https://example.com/photo.jpg">. This works, but the image loads from that other site every time someone visits your page, which can be slow and depends on that site staying online.
Styling the image link to remove the border
By default, browsers put a blue border around images that are links. If you don't want that border, add CSS to remove it. In your stylesheet, write:
a img { border: none; }
This targets any image inside an anchor tag and removes the border. You can also add other styles here — for example, opacity: 0.8; to make the image slightly transparent, or transform: scale(1.05); to make it grow slightly when someone hovers over it. These small effects help users understand the image is clickable.
Using images as buttons or navigation
Image links work well for navigation menus, logo links, or button-style elements. A common pattern is to make your site logo link back to the home page. You'd write something like <a href="index.html"><img src="logo.png" alt="Home"></a>.
If you're building a gallery or portfolio, you might link each thumbnail to a larger version of the image. The href would point to the full-size image file, and clicking the small version opens the large one.
Making image links accessible
The alt attribute is required for accessibility. Screen readers use it to tell users what the image is, so they understand where the link goes. Write alt text that describes the image or the destination — not just "image" or "photo". For example, alt="Learn about our pricing" is better than alt="button".
If the image is purely decorative and the link text is elsewhere on the page, you can use an empty alt attribute: alt="". This tells screen readers to skip the image and move on.
Common mistakes to avoid
The most common error is forgetting the closing anchor tag. If you write <a href="url"><img src="image.jpg"> without the </a>, the link won't work properly and may affect other elements on the page.
Another mistake is using a broken image path. If the src points to a file that doesn't exist, the browser shows a broken image icon instead of the picture. Check that the filename and folder path are exactly correct, including capitalization — Photo.jpg and photo.jpg are different files on most servers.
Don't forget the alt attribute. It's not optional — it's part of writing valid HTML and it helps people using screen readers understand your page.
Frequently Asked Questions
Can I make part of an image a link?
Not directly with a simple image tag. You'd need to use an image map, which defines clickable regions within a single image. This is rarely used anymore because it's hard to maintain and doesn't work well on mobile devices. A better approach is usually to use separate images or to overlay transparent buttons with CSS.
What if I want the image to link to an email address?
Use href="mailto:email@example.com" instead of a web URL. When someone clicks, their email client opens with a new message to that address. You can also add a subject line: href="mailto:email@example.com?subject=Hello".
How do I make an image link to a file download?
Put the file path in the href, just like you would for a web page: <a href="document.pdf"><img src="icon.png"></a>. When someone clicks, the browser downloads the file. You can also add download to the anchor tag to force a download instead of opening the file in the browser.
Can I use an SVG or GIF as a link?
Yes, the same method works for any image format — JPG, PNG, GIF, SVG, WebP, and others. The syntax stays the same: <a href="url"><img src="image.svg"></a>. SVGs are especially useful for logos and icons because they scale to any size without losing quality.