You can make an image clickable by wrapping it in an anchor tag. This creates a linked image that behaves like a normal link and is accessible when you include alt text and descriptive link context. Use rel=noopener when opening in a new tab.
How can you make an image clickable in HTML?
Use guided tracks for structured prep, then practice company-specific question sets when you want targeted interview coverage.
Overview
You can make an image clickable by placing it inside an <a> tag. The <a> tag defines a hyperlink, and any element inside it — including images — becomes clickable.
Step | Action |
|---|---|
1 | Add an <a> tag with an |
2 | Place the <img> tag inside the <a> tag. |
3 | Optionally, use |
Example: Basic Clickable Image
<a href="https://www.example.com">
<img src="logo.png" alt="Example Logo">
</a>
In this example, clicking the image takes the user to https://www.example.com.
Example: Opening in a New Tab
<a href="https://www.example.com" target="_blank">
<img src="logo.png" alt="Example Logo">
</a>
The target="_blank" attribute opens the linked page in a new browser tab.
Example: Clickable Image as a Button
<a href="/home" class="img-link">
<img src="home-icon.png" alt="Home">
</a>
<style>
.img-link img {
width: 80px;
border-radius: 8px;
transition: transform 0.2s;
}
.img-link img:hover {
transform: scale(1.05);
}
</style>
This example uses CSS to make the image behave like a stylish clickable button with hover effects.
Accessibility Tip
- Always provide a clear
altattribute describing the image’s purpose. - If the image represents navigation (like a button), the
alttext should describe the action, e.g., “Go to Home Page.”
Think of wrapping the image inside an <a> tag as placing a door on it — the picture stays the same, but now it leads somewhere when clicked.
- Wrap the <img> tag inside an <a> tag to make it clickable.
- Use
target="_blank"to open in a new tab. - Style it with CSS for button-like interaction.
- Always include descriptive
alttext for accessibility.