Click here to Skip to main content
13,199,311 members (52,326 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 1 Nov 2013

How To Add Image Links in HTML

, 4 Nov 2013
Rate this:
Please Sign up or sign in to vote.
Wherein the gentle reader is instructed on how to add images (which incorporate links) into his or her HTML

It has been said (too many times, perhaps) that a picture is worth a thousand words; actually, sometimes images are even more valuable than that, and can be worth a googleplex of words (depending on the picture, and depending on the words, of course).

Consider the difference in impact between this short list of books:

  • Cow County Chip by T.R. "Ticket Ted" Shannon
  • Autobiography of Mark Twain, Volume II by Samuel Langhorne Clemens
  • Still Casting Shadows Volumes I (1620-1913) and II (1914-2006) by B. Clay Shannon 
  • the Zany Time Travels of Warble McGorkle by Blackbird Crow Raven

...and this one, which adds corresponding images:

  • Cow County Chip by T.R. "Ticket Ted" Shannon

  • Autobiography of Mark Twain, Volume II by Samuel Langhorne Clemens

  • Still Casting Shadows Volumes I (1620-1913) and II (1914-2006) by B. Clay Shannon

  • the Zany Time Travels of Warble McGorkle by Blackbird Crow Raven

The latter is much more impressive, right? So it's really the combination of words and pictures that has the greatest impact. So how can you add image links like that to your HTML? Easy!

Just use one of these as a template:

For books and movies:

<a href="" target="_blank">
<img width="108" height="144" 

src="" /></a>

For recordings (MP3s, CDs):

<a href="" 

target="_blank"><img width="100" height="100" 

src="" /></a>

Replace the first tilde ("~") in those "templates" with the ASIN for the item. The "ASIN" is the number you will see usually following "/dp/" in the URL when you locate an item on Amazon's site. For example, if you searched for "Cow County Chip" (a book written by a retired CHP officer about his experiences in that line of work), the URL would be:

...and the ASIN embedded therein is 1481708139.

The second piece of information you need is the image link for the item. You can get that by going to and entering the ASIN into the "Product ASIN:" edit box, and your Amazon associate id (or mine: "garrphotgall-20") into the "Associate Tag:" edit box. I choose "large" for image size, but you can do whatever you want. Click the "Get HTML" button and retrieve the value in the "src=" portion of what is retrieved, which will be something like:


The "510YtCn4odL" portion (or whatever it happens to be with the item you entered) is what you want.

Replace the second tilde in the template with that value. Now you've got the HTML you need for displaying an image of an item that, when clicked on, will take the user to the item's Amazon page.

Of course, you can experiment with and adjust the height and width of the item, as specified in the HTML, to correspond to your needs/desires, and if you are an Amazon associate, you can change the associate id part of the HTML ("garrphotgall-20" in the example) with your own - but feel free to retain what is there, if you are not an Amazon associate.

Note: The image for the first book links to the author's web site instead of Amazon, as that is what he (my father) prefers. 

Note 2: I have added an HTML file for download which contains various books of NFL teams using the "template" above.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

B. Clay Shannon
Founder Across Time & Space
United States United States
I am in the process of morphing from a software developer into a portrayer of Mark Twain. My monologue (or one-man play, entitled "The Adventures of Mark Twain: As Told By Himself" and set in 1896) features Twain giving an overview of his life up till then. The performance includes the relating of interesting experiences and humorous anecdotes from Twain's boyhood and youth, his time as a riverboat pilot, his wild and woolly adventures in the Territory of Nevada and California, and experiences as a writer and world traveler, including recollections of meetings with many of the famous and powerful of the 19th century - royalty, business magnates, fellow authors, as well as intimate glimpses into his home life (his parents, siblings, wife, and children).

Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.

I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction, including a two-volume social and cultural history of the U.S. which covers important events from 1620-2006:

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171020.1 | Last Updated 5 Nov 2013
Article Copyright 2013 by B. Clay Shannon
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid