santa santa - 4 years ago 146
HTML Question

Remove line under image in link

I have a few instances where I place image within a link. Normally if you set border="0" there line under a link does not apply to the image. However, I had to specify DOCTYPE to be and now in FF I see the line under all images.

I still would like to have my links underlined, but not the images within.

<a href="link.php"><img src="img.png" height="16" width="16" border="0"> link</a>


I've tried to solve it with CSS by adding

a img {
text-decoration:none
}


Unfortunately it did not work. I also tried:

a img {
border:0
}


IE does not "underline" my images within a link... Any suggestions would be highly appreciated.

Example Link

enter image description here

I still would like to have my links underlined, but not the images within.

Answer Source

In case anyone cares, here's an alternative solution that I came up with to circumvent the issue:

.nl {
    text-decoration:none;
}
<a href="link.php" class="nl"><img src="img.png" height="16" width="16" border="0"><u>link</u></a>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download