Code for HTML Image Link Using Anchor Tag

Updated on 13 Feb 2012,
Published on 26 Jun 2008

The HTML anchor tag is used to create the Image link. You can insert the HTML image <img> inside the opening and closing <a> and </a> hyperlink anchor tags to create the image link. Image becomes clickable by applying the <a> tag on it. Use the href attribute of <a> tag to pass the location URL of destination page. Further you can specify the target attribute values of anchor tag to open the link in new window or same window when user clicks on image link. You can use "_blank" value for target attribute of <a> tag to open the image link in new window. By default without target attribute specified for <a> tag image link will open in the same parent window. There occurs only one problem while mapping link on HTML image <img> tag, by default it shows purple colored border of image link. But it can be resolved very easily by specifying border="0" attribute of <img> tag. You can also use style attribute of <img> by specifying the inline style to remove the border of <img>.

HTML Examples:

You can see the live samples and examples of HTML Basic tags from the following links:

Example for HTML Image Link using Anchor Tag

Example 1:
<a href="URL">
    <img src="ImageName.jpg"/>
</a>
Example 2:
<a href="URL">
<img src="ImageName.jpg" border="0" />
</a>
Example 3:
<a href="URL">
<img src="ImageName.jpg" style="border : 0px"/>
</a>
Example 4:
<a href="URL" target="_blank">
<img src="ImageName.jpg" border="0" />
</a>

Note: target attribute has been to "_blank" value to open the image link in new window.

Output:

You can see the output of above discussed sample code from the following link:

HTML Hyperlink Image Using Anchor Tag

Continue to next tutorial: HTML Hyperlink Anchor Tag CSS Styles to learn the color change rollover effects of HTML hyperlink text using CSS styles.

1 Responses to "Code for HTML Image Link Using Anchor Tag"
TKS
i need, pls, to link youtube in a slider
Leave a Comment
* required
* required
* will not be published
* optional
* hint: http://www.example.com
  • Subscribe via Email