Best Division

Spread Your Knowledge

  • All topics
  • About us
  • Contact us
  • Privacy policy
  • Terms of service
  • Copyright
  • Facebook
  • Twitter
  • Instagram
  • Youtube
  • LinkedIn
  • Pinterest
  • Github
  • Tumblr

© 2026 Best Division

How Do You Make an Image a Clickable Link in HTML?

HTML
Jayant Kumar
Jayant Kumar@jayantkumar314
PublishedNov 30, 2026
5 min read

To make an image a clickable link in HTML, place the <img> element inside an <a> element: <a href="/gallery"><img src="photo.jpg" alt="Open the photo gallery"></a>. The whole image becomes the link, and the alt text acts as the link text for screen readers. This is the standard html image link pattern.

The same technique works for logos, banners, product cards and thumbnails. The details that matter are the alt text, the focus outline and the image size.

Table of Contents

  • The basic image link
  • Writing alt text for a linked image
  • Removing the border and adding focus styles
  • Opening the link in a new tab
  • Image maps for several links in one picture
  • Linked images with captions and figures
  • Frequently Asked Questions
    • Can I make a background image clickable?
    • Should the image link also have a text label?
    • Does a linked image help SEO?
    • How do I stop the image from stretching on small screens?
  • Summary
  • Related Articles

The basic image link

An anchor can contain any inline content, including an image.

html

Clicking anywhere on the image opens the address in href. The mouse pointer turns into a hand, and the link can be reached with the Tab key.

Writing alt text for a linked image

When an image is the only content of a link, its alt text is the name of the link. Screen readers announce it as "link, MDN Web Docs".

Image purposeGood alt textPoor alt text
Site logo linking to the home pageAcme Shop homelogo
Product thumbnail linking to detailsBlue running shoe, size guideimage1.jpg
Banner linking to a sale pageSummer sale: up to 40% offempty alt

Describe where the link goes, not what the picture looks like. An empty alt="" is wrong here, because the link would have no accessible name at all.

If the link also contains text, the image is decorative and should have an empty alt so the name is not read twice.

html

Removing the border and adding focus styles

Old browsers drew a blue border around linked images. The HTML attribute border is obsolete, so control the look with CSS. Never remove the focus indicator without a replacement, because keyboard users need it.

html

Setting display: block on the image removes the small gap that sometimes appears under inline images and makes the clickable area match the picture.

Opening the link in a new tab

Use target="_blank" only when it helps the user, and say so in the name when the link leaves the page.

html

Current browsers apply noopener to target="_blank" by default, but writing it keeps older browsers safe.

Image maps for several links in one picture

When different parts of one image must go to different pages, use <map> and <area>.

html

Each <area> needs its own alt. Coordinates are in pixels of the displayed image, so image maps do not scale with a responsive image. For responsive layouts, use a link around each separate image or an SVG with links inside it.

Linked images with captions and figures

For a gallery or product card, combine the link with <figure> so the image and its caption share one target.

html

Two links to the same address next to each other are repeated noise for keyboard and screen reader users. A cleaner version puts one <a> around both the image and the caption text, and gives the image an empty alt. The loading="lazy" attribute delays images that are far below the fold, which speeds up long lists.

Frequently Asked Questions

Can I make a background image clickable?

A CSS background is not content, so wrap the element that has the background in an <a>, or make an <a> fill the box with display: block. Provide real link text, because a background has no alt.

Should the image link also have a text label?

Often yes. Visible text helps everyone and makes the target clearer. If you add text, set the image alt to empty.

Does a linked image help SEO?

Search engines use the alt text of a linked image as anchor text, so a descriptive alt matters. Keep it short and natural.

How do I stop the image from stretching on small screens?

Set max-width: 100% and height: auto in CSS, and keep the width and height attributes so the browser reserves space and avoids layout shift.

Summary

Wrap an <img> in an <a href> to make it clickable. Write alt text that names the link destination, style the focus state with CSS, and use <map> and <area> only when one picture needs several targets. Avoid the obsolete border attribute and keep the image responsive.

Related Articles

  • What Does the rel Attribute Do on HTML Links?
  • What Is the base Element and When Should You Use It?
  • Learn HTML: Complete Study Roadmap from Beginner to Advanced
Share