How to link an image to another page in HTML

Updated: 02/01/2021 by Computer Hope
<a> tag in HTML

On this page, we cover the steps in linking any image to another page. In the HTML (HyperText Markup Language) code, you will see a hyperlink tag with the href attribute and an image tag with the src attribute. The a href tag must contain the image tag to be linked to another page. Refer to the example below for an in-depth explanation of these terms.

HTML image link example code

<p>
 <a href="https://www.computerhope.com/">
  <img src="https://www.computerhope.com/cdn/media/logo-200.png">
 </a>
</p>

Example explained

First, the paragraph element (<p> tag) contains the image and hyperlink.

Next, the <a> tag is the hyperlink that is pointing to the Computer Hope website.

Next, the third line contains the <img> tag used to show the image. The src attribute tells the browser where the image is located.

Finally, the fourth and fifth line are the closing tags for the "a" and "p" tags opened earlier.

Example code result

Computer Hope Logo

In this example, clicking the image takes you to the Computer Hope homepage.