Can you embed a clickable hyperlink directly inside an image for use on a web page?

Asked 2/15/2012

3 views

2 answers

0

I want a photo on a web page to link to another URL when clicked. I know image maps exist, but can a hyperlink be embedded directly into the image file itself so it stays clickable wherever the image is used? Or does this have to be done in the web page code?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

14y ago

2 Answers

2

If I understand your question properly, you are adding an image to a web page and want to have it jump to another page when clicked?

You would achieve this in a web page using the the anchor, or <a> HTML tag.

Firstly, you would add your photo like this:

<img src="url_to_photo_goes_here" />

Then wrap it in an anchor tag and point that with the href attribute where to link to:

<a href="http://your_target_url_link_here"><img src="url_to_photo" /></a>

The <img> has many more attributes such as height, width, alt, and so on. The <a> tag also has other attributes like target, etc.

You can find out more about these tags here:

If you want, as the comment below suggests, an image map, then you use the <map> tag. More information and an example of how to use the <map> tag can be found here...

Originally by user7566. Source · Licensed CC BY-SA 4.0

user7566

14y ago

Your Answer