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

Viewed 32

I need to link this image in my website to another url but I cannot figure it out. I tried to use an <a> 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 class="portfolio-item padd-15">
          <div class="portfolio-item-inner shadow-dark">
            <div class="portfolio-img">
              <img src="images/CGS Official Logo 500 × 360 px.png" alt="">
            </div>
          </div>
        </div>
2 Answers

To add a link to your img tag surround it with your anchor tags.

See this snippet:

<div class="portfolio-item padd-15">
  <div class="portfolio-item-inner shadow-dark">
    <div class="portfolio-img">
       <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

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

img {
  width: 150px
}
<div class="portfolio-item padd-15">
  <div class="portfolio-item-inner shadow-dark">
    <div class="portfolio-img">
      <a href="https://stackoverflow.com/">
        <img src="https://images.unsplash.com/photo-1663668244836-68998f4e9151?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwyfHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=500&q=60" alt="">
      </a>
    </div>
  </div>
</div>

Related