How to Make Image Clickable in HTML: A Step-by-Step Guide for Beginners

By Cristian G. Guasch •  Updated: 09/18/23 •  8 min read

Creating clickable images in HTML is a simple yet highly effective way to make your website more interactive and user-friendly. If you’re new to web development, you might find the whole concept of making an image clickable somewhat daunting. However, I’m here to assure you that it’s not as complicated as it may seem.

HTML, or HyperText Markup Language, is the standard markup language used for creating websites. It allows us to transform static images into dynamic elements such as links or buttons. By making an image clickable, we can redirect our users to different parts of our site or even to another website entirely.

In this article, I’ll be showing you how to make an image clickable using HTML. We’ll cover everything from the basic structure of an HTML document to inserting images and creating hyperlinks. Whether you’re a seasoned developer looking for a quick refresher course or a complete beginner in the world of web development, this guide will have all your bases covered.

Understanding the Concept of Clickable Images in HTML

Ever wonder how to make an image clickable on a webpage? It’s simpler than you might think. The magic lies within the humble anchor tag <a> in HTML, which has been around since the dawn of web development. This element is primarily used to create hyperlinks, but it can also be used for clickable images.

Here’s a basic example:

<a href="">
  <img src="yourimage.jpg" alt="Description of Image">

In this snippet, we’ve nested an img tag inside an a tag. When someone clicks on the image (yourimage.jpg), they’ll be directed to the URL specified in your href attribute ( The alt attribute provides alternative text that describes what’s in the image – a crucial component for accessibility and should always be included.

Now let’s say you want to open the link in a new tab when users click on your image. You can do so by adding target="_blank" to your a tag:

<a href="" target="_blank">
  <img src="yourimage.jpg" alt="Description of Image">

And what if you want different parts of one image to lead to different URLs? That’s where “Image Maps” come into play:

<img src="yourimage.jpg" usemap="#mapname">

<map name="mapname">
  <area shape ="rect" coords ="x1,y1,x2,y2" href ="Link1.html">
  <area shape ="circle" coords ="x,y,radius" href ="Link2.html">

This example uses several new tags: <map><area>, and attributes like shape and coords. Here, we’ve created an image map that contains two clickable areas. One is a rectangle (rect) linking to Link1.html, the other is a circle (circle) linking to Link2.html.

And there you have it! These are just a few ways you can make images clickable in HTML. There’s always more to learn when it comes to web development, but understanding these basics will get you off to a great start.

Step-by-Step Guide: Making an Image Clickable in HTML

I’ve been there, staring at my screen, wondering how to make an image clickable in HTML. After countless hours of research and practice, I’ve mastered the art and now, I’m here to share that knowledge with you. So let’s jump right into it!

First thing’s first – we need an image. For my example, let’s use a picture of a cute puppy. Now it’s time to make this adorable little furball clickable! In HTML language, this is done using the <a> tag (also known as the anchor tag), which creates hyperlinks on your web page.

Here is an example:

<a href="">
   <img src="cute-puppy.jpg" alt="Cute Puppy">

In the code above, href attribute points to the URL you want to link to when your image is clicked. The src attribute for <img> tag tells where your image file lives while alt provides alternative text describing your image.

But what if you don’t want your linked page to open in the same tab? That’s simple! Just add the target="_blank" attribute like so:

<a href="" target="_blank">
   <img src="cute-puppy.jpg" alt="Cute Puppy">

As easy as pie – or should I say pup? With these simple steps, you can now turn any image into a clickable link leading anywhere on the internet. But remember, with great power comes great responsibility – always keep your users’ experience in mind when creating links!

Common Mistakes to Avoid When Creating Clickable Images

Creating clickable images in HTML might seem like a straightforward task, but there are common pitfalls that can trip up even experienced developers. I’ll guide you through some of these mistakes and provide examples to help you avoid them.

One misstep often comes from not linking the image properly. It’s crucial to remember that the <img> tag should be nested within the <a> tag, like so:

<a href="yourlink.html">
   <img src="image.jpg" alt="Clickable image"/>

Neglecting the alt attribute is another typical error. This attribute is meant to describe what’s in your image for those who can’t see it (like search engine bots or visually impaired users). Not using it could negatively impact your SEO and accessibility. Here’s an example of how it should look:

<img src="image.jpg" alt="A scenic view of mountains at sunset"/>

Inefficient sizing can also cause trouble when creating clickable images. While it might be tempting to adjust image dimensions directly in HTML, doing so can lead to distorted or pixelated visuals on different screen sizes or resolutions. It’s usually best practice to resize your images before uploading them, ensuring they display correctly across all devices.

Another thing worth mentioning is forgetting about mobile users. Touchscreen navigation means that smaller images may become difficult targets for users with larger fingers – so make sure your clickable elements are big enough!

Here’s a list of these common mistakes again for quick reference:

By being mindful of these errors and keeping my tips in mind, you’ll be well on your way to creating effective and engaging clickable images!

Advanced Techniques for HTML Clickable Images

I’m excited to delve into the more advanced techniques for creating clickable images in HTML. You might be wondering, “Why do I need advanced techniques?” Well, these methods can provide additional functionality and improve user experience.

Let’s start with one of my favorite techniques: using CSS to enhance the visual feedback of a clickable image. We know that adding a simple href tag can make an image clickable. But what if we want to show some change when the user hovers over the image? That’s where CSS comes into play!

<a href="your_link.html">
  <img src="your_image.jpg" alt="image description" class="hoverImage"/>

.hoverImage:hover {
   opacity: 0.7;

In this example, you see how we linked our image through an href tag and then used CSS to reduce its opacity whenever it’s hovered over. It gives users a clear indication that the image is interactive.

Next up is using JavaScript alongside HTML for added interactivity. For instance, we might want our page to respond in some way when an image is clicked – perhaps opening a pop-up or triggering an animation.

<img src="your_image.jpg" alt="image description" onclick="myFunction()"/>

function myFunction() {
   alert("You clicked on the image!");

Here, we’ve combined HTML and JavaScript so that clicking on our image triggers a function – in this case, displaying an alert message.

Lastly, let’s explore making part of an image clickable – yes, just part of it! This technique involves creating ‘hotspots’ within your images using <map> and <area> tags:

<img src="your_image.jpg" usemap="#image-map">

<map name="image-map">
    <area target="" alt="Area 1" title="Area 1" href="link1.html" coords="34,44,270,350" shape="rect">
    <area target="" alt="Area 2" title="Area 2" href="link2.html" coords="290,172,333,250" shape="circle">

In this case, we have two clickable areas within our image: a rectangle and a circle. Each area links to a different page.

All these techniques are examples of how you can push the boundaries of what’s possible with HTML clickable images. Remember that while these methods might be more complex than simply wrapping an image in an href tag, they can greatly enhance the interactivity and user experience of your web pages!

Cristian G. Guasch

Hey! I'm Cristian Gonzalez, I created HTML Easy to help you learn HTML easily and fast.

Related articles