Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

putting an img tag inside of an a href tag causes a border around image in IE

I have some HTML where I have img tags inside of an href tag to use as a button. Everything works fine except that when I open it in IE, I get a border around the img tag.

Here's some code:

<a href="javascript:changecolor(1)" title="Click Again to Change Color" style="cursor:pointer; text-decoration:none"><img src="button.png" width="25" height="25" style="margin-top:600px;" /></a> <a href="javascript:changecolor(2)" title="Click Again to Change Color" style="cursor:pointer"><img src="button.png" width="25" height="25" style="margin-top:600px;" /></a> <a href="javascript:changecolor(3)" title="Click Again to Change Color" style="cursor:pointer"><img src="button.png" width="25" height="25" style="margin-top:600px;" /></a> <a href="javascript:changecolor(4)" title="Click Again to Change Color" style="cursor:pointer"><img src="button.png" width="25" height="25" style="margin-top:600px;" /></a> <a href="javascript:changecolor(7)" title="Click Again to Change Color" style="cursor:pointer"><img src="button.png" width="25" height="25" style="margin-top:600px;" /></a> <a href="javascript:changecolor(6)" title="Click Again to Change Color" style="cursor:pointer"><img src="button.png" width="25" height="25" style="margin-top:600px; text-decoration:none" /></a> 

How can I get rid of the blue border, which only appears in IE?

like image 618
user541597 Avatar asked May 20 '11 01:05

user541597


People also ask

Which attribute of IMG tag create a border around an image?

The <img> border attribute is used to specify the border width around the image.

How do I remove the border from an image tag?

border: none; outline: none; the image is part of a sprite and there is no border around the image.

Can I put href on IMG?

To use image as a link in HTML, use the <img> tag as well as the <a> tag with the href attribute. The <img> tag is for using an image in a web page and the <a> tag is for adding a link. Under the image tag src attribute, add the URL of the image.

What should be the enclosing tag of IMG />?

<div /> into <div></div> .


1 Answers

Simple fix, in your stylesheet create a style similar to this:

a img{ border:0; } 

In your case, you could update your style to include some of the inline styles you have in your HTML. For example, your stylesheet would be updated to:

a{ cursor:pointer; text-decoration:none }  a img{ margin-top:600px; } 
like image 153
Dan Avatar answered Oct 08 '22 10:10

Dan