开发者

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

开发者 https://www.devze.com 2023-03-07 16:39 出处:网络
I have some HTML where I have img tags inside of anhref 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.

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 c开发者_运维知识库an I get rid of the blue border, which only appears in IE?


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;
}


Add border="0" attribute to the img tag


Regarding the minor issue with Internet Explorer and the grayed box around the anchor tag - this is outline. To hide the outline box you can use following CSS:

a img{outline:none;}
0

精彩评论

暂无评论...
验证码 换一张
取 消