Link to home
Start Free TrialLog in
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.
Avatar of Ian Meredith
Ian Meredith
Flag of Australia image

ASKER CERTIFIED SOLUTION
Avatar of Ian Meredith
Ian Meredith
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The reason why its pushed is because of the space between the a tag and the Image-Tag
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
Avatar of vsllc
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.