Home > Back-end >  How do I link this image in my website to another url using an <a> tag?
How do I link this image in my website to another url using an <a> tag?

Time:09-20

I need to link this image in my website to another url but I cannot figure it out. I tried to use an tag but when it deployed, I would click on the link and it still wouldn't redirect me. I'll attach the code below:

<div >
          <div >
            <div >
              <img src="images/CGS Official Logo 500 × 360 px.png" alt="">
            </div>
          </div>
        </div>

CodePudding user response:

To add a link to your img tag do it as such:

<div >
  <div >
    <div >
       <a href="https://google.com">
         <img src="images/CGS Official Logo 500 × 360 px.png" alt="image">
       </a>
    </div>
  </div>
</div>

I've added alt text so you can see the URL functioning as intended.

W3schools tag

CodePudding user response:

putting the img inside an anchor tag<a> <img> </a>

img {
  width: 150px
}
<div >
  <div >
    <div >
      <a href="https://stackoverflow.com/">
        <img src="https://images.unsplash.com/photo-1663668244836-68998f4e9151?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwyfHx8ZW58MHx8fHw=&auto=format&fit=crop&w=500&q=60" alt="">
      </a>
    </div>
  </div>
</div>

  •  Tags:  
  • html
  • Related