65.9K
CodeProject is changing. Read more.
Home

Remove blue border when image is inside the hyperlink

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.94/5 (9 votes)

Mar 7, 2011

CPOL
viewsIcon

15433

DescriptionI...

Description

If one would want to restrict the no-border CSS rule only to certain images inside any anchor tags, it is advised to use a class CSS selector rule:

CSS Code

<style type="text/css">
    a img.noborder
    {
        border: none;
    }
</style>

Usage

Using that in your HTML would look like this:
<a href="http://www.codeproject.com"><img src="Bobette.gif" alt="No border to see here!" class="noborder" /></a>

Note:

The same way that E#XYZ can be used to select any HTML element E with its attribute id set to XYZ the . can be used in E.XYZ to select any element E where its attribute class set to XYZ.