Menu DaniWeb
Log In Sign Up
  • Read
  • Contribute
  • Meet
  1. Forums
  2. Digital Media
  3. UI / UX Design
  4. Code Snippet Repository
  5. Reusable Code Snippet

Set an image as a link

21 Years Ago helloadam 0 Tallied Votes 224 Views Share

This snippet shows you how to add set an image as a link.

1) In the snippet find

<a href="IMAGE URL WHEN CLICKED">

and change Image Url when clicked to your liking.
2) Then find

<img border="0" src="URL OF IMAGE " width="65" height="38">

edit Url Of Imge to your liking.
3) If all went well you are done!

graphics:image web-design
<a href="IMAGE URL WHEN CLICKED">
<img border="0" src="URL OF IMAGE " width="65" height="38">
</a>
About the Author
Member Avatar for helloadam
helloadam 0 Light Poster

meh nothing yet...

Dani AI

Generated 7 Months Ago

showed the core idea — wrap an image in an anchor to make it clickable — but a few modern, practical tweaks make that pattern robust, accessible, and future‑proof.

Always provide meaningful alt text (or alt="" for purely decorative images). Prefer CSS over deprecated presentational attributes (avoid border="0" in markup). Include the image’s intrinsic width and height attributes so browsers can reserve space (reduces layout shift), and then control sizing with CSS or srcset/sizes for responsive images.

To answer about the 65×38 values: those are fixed sizes and were likely chosen to match the image used. Today the recommended approach is to set the image’s real pixel width/height in HTML (so the browser knows the aspect ratio) and then scale visually in CSS:

/* reserve aspect ratio in HTML, but make images responsive in CSS */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

To address and the “red lines” in old IE: those were browser focus/border behaviors. Use CSS to remove the default image border and — critically — provide a custom focus style so keyboard users still get visible focus:

a img { border: 0; }           /* remove old image borders */
a:focus, a:focus img {
  outline: 3px solid #1a73e8;  /* visible, custom focus for accessibility */
  outline-offset: 2px;
}

For : “drop my link URL with normal word” means using anchor text instead of an image. Use descriptive text (better for accessibility and SEO) — avoid “click here”:

<a href="https://example.com">Download the brochure</a>

If the image is the link target, make its alt describe the destination (or use the same phrasing as the anchor text). Avoid removing focus outlines altogether — style them instead so links remain usable for keyboard and assistive‑technology users.

Member Avatar for Dani
Dani 5,664 The Queen of DaniWeb Administrator Featured Poster
21 Years Ago

Why are you setting the width and height of the image to 65x38 pixels in size?

Member Avatar for helloadam
helloadam 0 Light Poster
21 Years Ago

Oops!

Member Avatar for tuputips
tuputips 0 Newbie Poster
19 Years Ago

I Don't Like That Red Lines Around My Picture In IE 6. What About Mozilla!!?

Member Avatar for uringinteristi
uringinteristi 0 Newbie Poster
17 Years Ago

thank you your for your code

Member Avatar for uringinteristi
uringinteristi 0 Newbie Poster
17 Years Ago

how to make snip code to drop my link URL with normal word?

Reply to this topic
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.

Sign Up — It's Free!
Recommended Topics
  • Member Avatar Image Map Works in IE but not in Firefox 12
  • Member Avatar How to create image maps that look so nice... 8
  • Member Avatar tables vs divs & workflow advice? And a list for CSS workarounds for browsers? 8
  • Member Avatar stretch background image 1
  • Member Avatar loading an html file into a div from a link 2
  • Member Avatar How to make an image unsaved? 9
  • Member Avatar LogoDesignz 22
  • Member Avatar joomla-like image scroll 0
  • Member Avatar Image Swap help 4
  • Member Avatar Image inside a panel? 2
  • Member Avatar How do I center extend the nav bar to fit in the body of the page 3
  • Member Avatar How to show image in place of swf if flash player is not installed in browser ! 1
  • Member Avatar Where Can I Find Free Images? 3
  • Member Avatar check for images duplication 4
  • Member Avatar create a continuous marquee in flash... 3
  • Member Avatar Image overlaps table below 3
  • Member Avatar Jump to another part of a document (on the same page) 11
  • Member Avatar Image Position Moves on Resize of Window 6
  • Member Avatar image with link in menu for e107 3
  • Member Avatar Image file upload to thumbnail 6
Not what you need?

Reach out to all the awesome people in our ui / ux design community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.

Start New Topic
Topics Feed
Reply to this Topic
Edit Preview

Share Post

Insert Code Block

  • Forums
  • Forum Index
  • Hardware & Software
  • Programming
  • Digital Media
  • Community Center
  • Recent
  • Recommended Topics
  • Newest Topics
  • Latest Topics
  • Latest Posts
  • Latest Comments
  • Top Tags
  • Tools
  • Writing
    • Start New Topic
    • Markdown Syntax
    • Newsletter Archive
  • Social
    • Top Members
    • Meet People
  • APIs
    • Connect API
    • Forum API Docs
    • Topics Feed
  • Resources
  • Community Rules
  • DaniWeb Premium
  • FAQ
  • About Us
  • Advertise
  • Contact Us
  • Legal
  • Terms of Service
  • Privacy Policy
© 2026 DaniWeb® LLC
© 2026 DaniWeb® LLC
  • FAQ
  • About Us
  • Advertise
  • Contact Us
  • Terms of Service
  • Privacy Policy