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.
An anchor can contain any inline content, including an image.
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.
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 purpose | Good alt text | Poor alt text |
|---|---|---|
| Site logo linking to the home page | Acme Shop home | logo |
| Product thumbnail linking to details | Blue running shoe, size guide | image1.jpg |
| Banner linking to a sale page | Summer sale: up to 40% off | empty 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.
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.
Setting display: block on the image removes the small gap that sometimes appears under inline images and makes the clickable area match the picture.
Use target="_blank" only when it helps the user, and say so in the name when the link leaves the page.
Current browsers apply noopener to target="_blank" by default, but writing it keeps older browsers safe.
When different parts of one image must go to different pages, use <map> and <area>.
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.
For a gallery or product card, combine the link with <figure> so the image and its caption share one target.
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.
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.
Often yes. Visible text helps everyone and makes the target clearer. If you add text, set the image alt to empty.
Search engines use the alt text of a linked image as anchor text, so a descriptive alt matters. Keep it short and natural.
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.
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.