Learn how to make an image clickable in HTML with two easy-to-follow steps.
Step 1: Create an image
The first step is to add an image that you want to make clickable. In the HTML file, add the
img element tag and then insert the location of the image into the
Do not forget to include the
alt attribute to improve the accessibility of your website.
<img src="./cat.jpg" alt="a cat staring at you" />
Step 2. Add a link to an image
The second step is to add a link to an image so that it will be clickable. To do that, wrap the
a element tag around the
img element tag.
After that, add the link address in the
href attribute of the
a element tag.
<a href="https://js.coderslang.com/"> <img src="./cat.jpg" alt="a cat staring at you" /> </a>
And you are all done! That is how you make an image clickable in HTML. When you head back to the browser and click the picture, it will take you to another page.