Avatar of vsllc
vsllc
 asked on

Add hyperlink to image

This is probably a very basic questions, but I'm have very little knowledge of coding.  I have an image on my website, code below, and I want to make the entire image a hyperlink that when clicked will go to a new web page.  How do I do this?

<img src="images/demo/test.png" border="0" alt="Test" width="220" height="454" />

I've tried this but it pushes the images below it down a couple of pixels from how they displayed without hyperlink.

<p><a href="http://www.yahoo.com"> <img src="images/demo/test.png" border="0" alt="Test" width="220" height="454" /></a></p>

Thanks.
Scripting LanguagesImages and PhotosWeb Languages and Standards

Avatar of undefined
Last Comment
vsllc

8/22/2022 - Mon
Ian Meredith

ASKER CERTIFIED SOLUTION
Ian Meredith

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
John Claes

The reason why its pushed is because of the space between the a tag and the Image-Tag
Dewmec

Hi vslic,

You will also want to add the "target="_blank" to get your hyperlink to open in a new page. Such as the following:
<p><a href="http://www.yahoo.com" target="_blank"> <img src="images/demo/test.png" border="0" alt="Test" width="220" height="454" /></a></p>

Open in new window

That should allow you to click on the image test.png and it should open in a new tab or window in the browser to the yahoo.com website. Let me know how you make out with this.

Dewmec
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
vsllc

ASKER
poor beggar - I adjusted but it didn't change the spacing issue.

dewmec - thanks for the tip.  For this purpose I am OK with it not opening a new window.