tags:

views:

382

answers:

3

hello, i set up a style for all my links but the problem is that any anchor that has an image obviously will have the same style.

is there any way i can overwrite the style for the images without having to apply a class to all the images that removes that style?

+3  A: 
a img {
 /* alternative style for hyperlinked images */
}
BipedalShark
A: 

No, there is no CSS selector which will capture <a> elements which contain only an <img> element. You will need to apply a class either at design-time or at run-time with javascript.

Ken Browning
+1  A: 

I would recomend rewriting your code to not use images but for your links with images just use clickable divs displayed as blocks.

<div id="x"><a href=".." class="y"></a></div>


.y {
display: block;
}

#x {
width:..;
height:..;
padding:0;
margin:0;
background-image:url(IMGPATHHERE!);
}

#x:hover {
width:..;
height:..;
padding:0;
margin:0;
background-image:url(THEHOVERIMGHERE!);
cursor:hand;
}
Jacob Nelson