Computer >> Computer tutorials >  >> Programming >> HTML

How to use an image as a link in HTML?


To use image as a link in HTML, use the <img> tag as well as the <a> tag with the href attribute. The <img> tag is for using an image in a web page and the <a> tag is for adding a link. Under the image tag src attribute, add the URL of the image. With that, also add the height and width.

How to use an image as a link in HTML?

Example

You can try to run the following code to use an image as a link in HTML

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Image as link</title>
   </head>
   <body>
      The following image works as a link:<br>
      <a href="https://www.qries.com/">
         <img alt="Qries" src="https://www.qries.com/images/banner_logo.png"
         width=150" height="70">
      </a>
   </body>
</html>