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 DOC
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>
Solved
<a href="link.php" style="text-decoration: none"><img src="img.png" height="16" width="16" border="0"> link</a>
If you are linking to an image, try the following:
a[href$=jpg], a[href$=png] {
text-decoration: none;
}
a { text-decoration: none }
The underline is from the A-tag not the IMG
For those cases where editing the markup isn't an option (inaccessibility to templates and/or surrounding issues), you can use a little jQuery. You may need to adjust the syntax to override your CSS:
jQuery('a > img').parent().css({'text-decoration' : 'none'});
If you want to have a special case for links with images, give the a
element a class and remove the text-decoration for that class:
HTML:
<a href="link.php" class="image-link"><img height="16" width="16" /></a>
CSS:
a img
{
border: 0 none;
}
.image-link
{
text-decoration: none;
}
This is great if you only have an image within the link, however you have both text and images within the anchor.
The solution for that would be to add a span
around the text within the anchor:
<a href="link.php" class="image-link"><img height="16" width="16" /> <span>link text here</span></a>
and add an additional style in the stylesheet:
.image-link span
{
text-decoration: underline;
}